-1

I am trying to fill a DataTable with a List that was filled by a result queried by a native sql.

Object array defines the value of each columns, for expample Object[0] is the value of the first column.

My dataTable is something like this

<p:dataTable id="dataTable1RQ" var="item" value="#{reportQuestionMBean.dataTable}">  
    <p:column id="modelHeader">  
        <f:facet name="header">  
                Market  
        </f:facet>  
        <h:outputText value="#{reportQuestionMBean.market.name}" />  
    </p:column>  
    <p:column>  
        <f:facet name="header">  
                Form  
        </f:facet>  
        <h:outputText value="#{reportQuestionMBean.form.name}" />  
    </p:column>  
    <p:column>  
        <f:facet name="header">  
                Question  
        </f:facet>  
        <h:outputText value="#{item}" />  
    </p:column> 
</p:dataTable>

I want to fill the column 'Question' but I cannot reach the index of the Object array in the List. If it was a specific class instead of Object[], it would be easy to fill by implementing like this

<h:outputText value="#{item.name}" />

But it is not. So if you know how to reach the index of an array in a list, your help will make me preciated.

Thanks.

4

1 回答 1

4

您可以在 EL 中使用大括号表示法[]通过索引访问数组项。

所以,这应该做

<h:outputText value="#{item[0]}" />
于 2012-07-15T02:50:29.653 回答