2015-10-06 51 views
1

我想爲我的數據表中的每一行顯示圖像。我從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.E​​[email protected] class org.omnifaces.el.E​​xpressionInspector $ FinalBaseHolder to class java.lang.Integer

jsf 2.2.12,Tomcat 8.0.14,jdk 8,omnifaces 2.1

+0

根據迄今爲止提供的相關信息(但是使用Tomcat 8.0.26而不是8.0.14,所以也許會有所不同),我無法再現問題。請按照http://stackoverflow.com/tags/jsf/info中的要求創建一個MCVE。在我的情況下,我用這個MCVE:http://pastebin.com/wfD9hTPu – BalusC

+0

@BalusC問題是我使用舊版本的el-impl(jboss-el 2.0.1.GA)而不是基於容器。當我改變這一點時,問題就消失了。謝謝。 – Nikola

回答

0

根據註釋,問題已由OP解決。

問題是我使用舊版本的el-impl(jboss-el 2.0.1.GA)而不是基於容器。當我改變這一點時,問題就消失了。謝謝。

相關問題