在某些情况下,我在尝试在 facelet 页面(从数据库中检索)上显示图像并且页面由 URL(不是 h:commandLink )。它适用于通过 h:commandButton 处理请求的其他页面。然而,除了图像之外的所有数据都出现在以下场景中......
fundraiseView.xml (facelet 页面) html ... p:graphicImage value="#{fundraisePage.picture}"/ ... /html
FundraisePage(带有请求参数的请求范围内的支持 bean)
@ManagedBean @RequestScoped public class FundraisePage extends BackingBean { @EJB DataSBLocal dataSB; StreamedContent picture; @ManagedProperty(value="#{param.id}") private int id; @PostConstruct public void init() { this.fundRaiseEO = dataSB.getFundRaiseIndividual(id); InputStream inputStream = new ByteArrayInputStream(this.fundRaiseEO.getPicture()); this.setPicture(new DefaultStreamedContent(inputStream, "image/jpeg")); }
当我通过http://...../faces/fundraiseView.xml?id=1调用页面时,页面返回显示 id 1 的所有数据,但不显示图片。我确信这与我调用页面的方式有关(因为我让它在其他地方工作)但是我需要它是在 JSF 包装标签之外发起的请求。
非常感谢任何见解或建议。
谢谢,乔纳森