1
다음 코드가 있습니다. 반복 부분에 이미지가 표시 될 수 있지만 이미지를 클릭하면 명령 링크와 setPropertyActionListener가 제대로 작동하지만 이미지가 제대로 표시되지 않습니다. 필수 패널 그리드.p : graphicImage에 이미지를 표시 할 수 없습니다.
<p:layoutUnit id="centre" position="center" >
<h:panelGrid id="test" columns="2" cellpadding="2" >
<h:panelGroup>
<div id="imageWrap" style="width:600px; height:400px; margin:auto; overflow:scroll; position:relative;">
<p:graphicImage id="prodImage" value="#{imageController.image}" alt="unable to load image #{imageController.imageID}" />
</div>
</h:panelGroup>
</h:panelGrid>
</p:layoutUnit>
<p:layoutUnit id="left" position="west" >
<h:panelGrid id="panelGrid3" columns="2" cellspacing="2" cellpadding="2">
<ui:repeat id="repeat5" value="#{getData.imageThumbnail1}" var="imagesLst" varStatus="loop">
<h:panelGroup>
<p:commandLink update=":form:tabView:test" >
<f:setPropertyActionListener target="#{imageController.imageID}" value="#{imagesLst.imageID}" />
<p:graphicImage id="gi5" value="#{imagesStreamer.image}" alt="image not available" >
<f:param name="id" value="#{imagesLst.imageID}" />
</p:graphicImage>
</p:commandLink>
</h:panelGroup>
</ui:repeat>
</h:panelGrid>
</p:layoutUnit>
지지 빈이
@ManagedBean
@SessionScoped
public class imageController implements Serializable {
private String imageID;
private StreamedContent sc;
/** Creates a new instance of imageController */
public imageController() {
}
public void setImageID(String imageID) {
this.imageID = imageID;
System.out.println("ImageController set == "+ this.imageID);
}
public String getImageID(){
return imageID;
}
public StreamedContent getImage() {
System.out.println("ImageController get == "+ this.imageID);
if (imageID != null) {
ByteArrayInputStream image = GetData.findImages(imageID);
System.out.println("Passing Default Streamed Content");
return new DefaultStreamedContent(image);
}
return sc;
}
}
'이미지 # {imageController.imageID}를로드 할 수없는 "선택된 이미지 ID를 표시하지만 그래픽 패널의 화상을 볼 수 없다. 또한 로그에 오류 메시지가 표시되지 않고 streamedcontent가 반환됩니다.
UPDATED CODE : 1
<p:layoutUnit id="centre" position="center" >
<h:panelGrid id="test" columns="2" cellpadding="2" >
<h:panelGroup>
<div id="imageWrapper" style="width:600px; height:400px; margin:auto; overflow:scroll; position:relative;">
<p:graphicImage id="Img1" value="#{imagesStreamer.image}" alt="image id to be displayed #{imagesLst.imageID}" >
<f:param name="id5" value="#{imagesLst.imageID}" />
</p:graphicImage>
</div>
</h:panelGroup>
</h:panelGrid>
</p:layoutUnit>
<p:layoutUnit id="right" position="east" >
<h:panelGrid id="panelGrid3" columns="2" cellspacing="2" cellpadding="2">
<ui:repeat id="repeat5" value="#{getData.imageThumbnail1}" var="imagesLst" varStatus="loop">
<h:panelGroup>
<p:commandLink id="cl5" update=":form:tabView:test">
<p:graphicImage id="gi5" value="#{imagesStreamer.image}" alt="image not available3" >
<f:param name="id5" value="#{imagesLst.imageID}" />
</p:graphicImage>
</p:commandLink>
</h:panelGroup>
</ui:repeat>
</h:panelGrid>
</p:layoutUnit>
위의 업데이트 된 코드를 확인하고 변경 사항을 적용한 다음 f : setPropertyActionListener 부분을 제거합니다. 관리되는 bean imagesStreamer.image에서 데이터가 반환되지만 페이지에는 보이지 않습니다. 이미지지만 alt 부분 만. – user1433804
나는 그것을 가장 현기증 나는 방법으로, 내가 arraylist에서 ByteArrayInputStream을 저장하고 있었다 - 동일한 페이지에서이 값을 다시 전달하면 (적어도 나를 위해) 작동하지 않는다. 이제 arraylist에 하나의 값을 더하여 ByteArrayOutputStream ByteArrayInputStream으로 변환 한 다음 Streamed Content로 변환하면 어떻게 든 작동합니다. 같은 것을하기위한 더 좋은 방법이 무엇인지 알아야합니다. 대부분의 질문에 답변을 게시 해 주신 BalusC에게 감사드립니다. 질문이 없으면 큰 공헌 (지식)을 유지하십시오. – user1433804