<p:dataTable id="fileList" value="#{yeniBelgeBean.listResim}" var="fileList">
<p:column headerText="Dosya İsmi" >
<h:outputText value="#{fileList.ad}" />
</p:column>
<p:column headerText="Resim">
<p:graphicImage id="graphImage" width="100" height="100" value="#{yeniBelgeBean.image}">
<f:param name="id" value="#{fileList.id}" />
</p:graphicImage>
</p:column>
<p:column headerText="Seç">
<p:commandButton id="senImmage" value="Goster" actionListener="#{userBean.ataID(fileList.id)}" process="@this" update="@form" />
</p:column>
</p:dataTable>
Bean是(会话作用域)
private GtbEtobsResim selectedResim = new GtbEtobsResim();
public List<GtbEtobsResim> getListResim() {
return listResim = service.listFiles(selectedResim.getBelgeNo());
}
public StreamedContent getImage() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String idStr = context.getExternalContext().getRequestParameterMap().get("id");
selectedResim = service.getImageFile(Long.valueOf(idStr));
StreamedContent img = new DefaultStreamedContent(new ByteArrayInputStream(selectedResim.getResim()), "image/png");
//return new DefaultStreamedContent(new ByteArrayInputStream(im.getResim()));
return img;
}
}
UserBean是(会话作用域)
public void ataID(Long id){
this.id=id;
}
当我按下命令按钮时,我想下载具有相同BELGE_NO的图像。 在primefaces或任何jsf组件中的任何解决方案。