我正在尝试为我的数据表中的每一行显示图像。我从omnifaces举了一个例子:
<!-- Table with role list -->
<p:dataTable id="idRolesTable" value="#{staffMB.roleNestedList}" var="row"
paginatorAlwaysVisible="false" paginator="#{userSessionMB.getWebOption('paginator')}"
paginatorTemplate="#{userSessionMB.paginatorTemplate}" selection="#{staffMB.selectedRole}" selectionMode="single"
paginatorPosition="#{userSessionMB.getWebOption('paginatorPosition')}" rowsPerPageTemplate="10,15,20,50"
rows="10" emptyMessage="#{contentMB.msg.label_noItemsFound.value}" rowKey="#{row.pid}" widgetVar="roleTable"
tableStyle="table-layout: fixed;" filteredValue="#{staffMB.filteredRoleList}">
<!-- Image -->
<p:column id="slRoleImageColumn" headerText="#{contentMB.msg.label_id.value}" sortBy="#{row.roleId}" style="width:5%;"
filterBy="#{row}" filterFunction="#{staffControllerMB.filterByRoleId}">
<o:graphicImage value="#{imagesMB.getImage(row.ownerPerson.documentId)}" width="50"/>
</p:column>
使用 ImageMB 类:
@ManagedBean(name = "imagesMB")
@ApplicationScoped
public class ImagesMB extends BaseControllerMB {
private static final long serialVersionUID = 7074295738016877803L;
@ManagedProperty(value = "#{documentManager}")
protected IDocumentManager documentManager = null;
public byte[] getImage(Integer docId) {
PpbDocsDbBean image = documentManager.getDefaultDocument(docId);
if (image == null)
return null;
Integer size = image.getPptDfiles().getDoclen();
byte[] byteArrayDocument = image.getPptDfiles().getDocstore().getFixedByteArray(size);
return byteArrayDocument;
}
有一个例外:
无法将 org.omnifaces.el.ExpressionInspector$FinalBaseHolder 类型的 org.omnifaces.el.ExpressionInspector$FinalBaseHolder@140f4b22 转换为 java.lang.Integer 类
jsf 2.2.12、Tomcat 8.0.14、jdk 8、omnifaces 2.1