Datatable column row with more than one attribute

2

I have a multi-column Datatable. One of them is a column that should display more than one attribute on each row of that column because it is part of a ManyToMany relationship. This column will receive the attributes of a List. I want to know how to display more than one attribute in the rows of this column

The datatable with the column

<p:dataTable id="monografiasDataTable" widgetVar="monografiaTable"
                value="#{gestaoMonografiasBean.listaMonografias}" var="monografia"
                emptyMessage="Nenhuma informação a ser exibida" paginator="true"
                rows="10" paginatorPosition="bottom" selectionMode="single"
                selection="#{gestaoMonografiasBean.monografia}"
                rowKey="#{monografia.id}" >

                <p:ajax event="rowSelect" update="frm:toolbar" />

                <p:ajax event="rowUnselect" update="frm:toolbar" />

            <p:column filterBy="#{monografia.listaLinhaPesquisas[0].nome}" headerText="Linha de Pesquisa">
                <f:facet name="filter" >
                    <p:selectCheckboxMenu  value="#{gestaoMonografiasBean.listaMonografiasFiltradas}" label="Selecione" onchange="PF('monografiaTable').filter()"
                        converter="omnifaces.SelectItemsConverter"> 
                        <f:selectItems
                            value="#{gestaoMonografiasBean.listaLinhaPesquisas}"
                            var="listaLinhaPesquisas"
                            itemLabel="#{listaLinhaPesquisas.nome}"
                            itemValue="#{listaLinhaPesquisas}"/>
                    </p:selectCheckboxMenu>
                </f:facet>
                <h:outputText value="#{monografia.listaLinhaPesquisas[0].nome}" />

            </p:column> 
    
asked by anonymous 28.03.2018 / 00:44

2 answers

1

A column of a datatable will show you as many things as you put in your declaration. Assuming you want to use a second array index shown would do the following:

<p:column filterBy="#{monografia.listaLinhaPesquisas[0].nome}" headerText="Linha de Pesquisa">
    <f:facet name="filter" >
        <p:selectCheckboxMenu  value="#{gestaoMonografiasBean.listaMonografiasFiltradas}" label="Selecione" onchange="PF('monografiaTable').filter()"
                        converter="omnifaces.SelectItemsConverter"> 
               <f:selectItems
                            value="#{gestaoMonografiasBean.listaLinhaPesquisas}"
                            var="listaLinhaPesquisas"
                            itemLabel="#{listaLinhaPesquisas.nome}"
                            itemValue="#{listaLinhaPesquisas}"/>
                </p:selectCheckboxMenu>
    </f:facet>
    <h:outputText value="#{monografia.listaLinhaPesquisas[0].nome}" /> 
    <br/>
    <h:outputText value="#{monografia.listaLinhaPesquisas[1].nome}" />    
</p:column> 

I've added this snippet here:

<br/>
<h:outputText value="#{monografia.listaLinhaPesquisas[1].nome}" /> 
    
28.03.2018 / 10:31
0

The question was silly, but I will leave here what solved my problem that can help other people. I used the Datalist and solved my problem.

<p:dataList value="#{monografia.listaLinhaPesquisas}" var="linhaPesquisa">
                    <h:outputText value="#{linhaPesquisa.nome}" />
                </p:dataList>
    
28.03.2018 / 12:19