Primefaces 具有流式内容的动态图像
根据找到的解决方案,我实现了两个StreamedContentBean来动态加载图形图像 1) 对于第一个,我在contentFlow中显示图像(一切正常)Primefaces 具有流式内容的动态图像,primefaces,jsf-2,graphicimage,Primefaces,Jsf 2,Graphicimage,根据找到的解决方案,我实现了两个StreamedContentBean来动态加载图形图像 1) 对于第一个,我在contentFlow中显示图像(一切正常) 由于您使用的是primefaces,请尝试使用p:repeat Repeat是标准Repeat组件的扩展,提供JSF实现和PrimeFaces组件之间的互操作性 您能提供托管bean代码吗?如果我将bean的作用域更改为RequestScoped而不起作用,我已将其添加到问题。您的意思是更改图像拖缆的范围吗?这对你的申请来说应该一点问题都
由于您使用的是primefaces,请尝试使用
p:repeat
Repeat是标准Repeat组件的扩展,提供JSF实现和PrimeFaces组件之间的互操作性
您能提供托管bean代码吗?如果我将bean的作用域更改为RequestScoped而不起作用,我已将其添加到问题
。您的意思是更改图像拖缆的范围吗?这对你的申请来说应该一点问题都没有。对不起,我出了点问题。。。现在它开始工作了。。。我真的不知道为什么…对不起,我有点不对劲。。。现在它开始工作了。。。我真的不知道为什么。。。我用了c:foreach
<p:contentFlow value="#{imageBean.images}" var="image">
<p:graphicImage value="#{imageStreamer.fileContent}" styleClass="content" cache="false">
<f:param name="index" value="#{image.index}"/>
</p:graphicImage>
</p:contentFlow>
<c:forEach items="#{imageBean.images}" var="item" varStatus="varStatus">
<p:graphicImage value="#{imageStreamer.fileContent}" cache="false">
<f:param name="index" value="#{varStatus.index}" />
</p:graphicImage>
</c:forEach>
@ManagedBean
@ApplicationScoped
public class ImageStreamer{
public ImageStreamer(){}
public StreamedContent getFileContent(){
List<Link> links = this.getLinkItems();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
FacesContext fc = FacesContext.getCurrentInstance();
String linkIndex = externalContext.getRequestParameterMap().get("index");
if(fc.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE){
return new DefaultStreamedContent();
}else{
int parsedIndex = Integer.parseInt(linkIndex);
Link ql = links.get(parsedIndex);
return new DefaultStreamedContent(new ByteArrayInputStream(ql.getBytes()), "image/png");
}
}
}