我在数据网格列中显示图像时遇到问题。当 Datagrid 加载它正确显示图像但每当我点击第二页或刷新第一页时,图像就消失了。我在控制台中注意到,单击第二页或刷新页面使参数值为空。这就是为什么图像没有显示。我正在使用会话范围。下面是我的代码:
 public StreamedContent getStreamedImageById() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getRenderResponse()) {
    // So, we're rendering the view. Return a stub StreamedContent so that it will generate right URL.
    System.out.println("check");
    return new DefaultStreamedContent();
}
else {
    // So, browser is requesting the image. Get ID value from actual request param.
    String firstName = context.getExternalContext().getRequestParameterMap().get("firstName");
    System.out.println("Name:"+firstName);
    System.out.println("Image::"+images.get(firstName));
    return images.get(firstName);
}
在搜索方法中,我只取散列图中的所有图像。
      while(itr.hasNext()){
                com.sysvana.request.UserBean us=itr.next();
            images.put(us.getFirstName(), stringToStreamedContent(us.getJpegPhoto()));
            }
这是我的 xhtml::
         <p:graphicImage value="#{userManagementActionBean.streamedImageById}" height="40" width="50" style="align:center"  >
                <f:param id="firstName" name="firstName" value="#{user.firstName}" />
              </p:graphicImage>