【发布时间】:2013-11-18 16:37:53
【问题描述】:
我尝试在每个人的数据表中显示来自 db 的一些图像,但数据表显示错误的图像。我不知道应用程序从哪里获取正在显示的图像,因为在支持 bean 中,图像是其他的。
<p:column>
<p:graphicImage id="img2" value="#{listadoPersonasMB.fotoPersona}">
<f:param name="id2" value="#{item.idPersona}" />
</p:graphicImage>
</p:column>
支持豆
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String studentId = context.getExternalContext().getRequestParameterMap().get("id2");
FacesContext ctx = FacesContext.getCurrentInstance();
ValueExpression vex = ctx.getApplication().getExpressionFactory().createValueExpression(ctx.getELContext(), "#{controladorMB}", ControladorMB.class);
ControladorMB gMB = (ControladorMB) vex.getValue(ctx.getELContext());
return new DefaultStreamedContent(new ByteArrayInputStream(gMB.getPersonaBean().devuelveFotoPersona(Integer.parseInt(studentId))));}
【问题讨论】:
标签: jsf-2 primefaces