JSF datatable how to fill columns with List<List<Integer>?

Asked

Viewed 1,016 times

2

I have the following situation. A vector that will store the values that will be registered in the bean

public class PainelControleExtratoVO {
    public Integer[] demandaEmAberto;
    public Integer[] demandaEmProcesso;
    public Integer[] demandaAguardandoCliente;
    public Integer[] demandaArguardandoOperadora;
    public Integer[] demandaCancelada;
    public Integer[] demandaFechamento;
}

The values that are filled are already correct and properly placed in the vector

@KeepAlive
public class PainelControleExtratoBean extends BaseLocalBean<PainelControleExtrato>{

    @SuppressWarnings("unchecked")
    public String prepareList(){

        listPainelControleExtrato = new ArrayList<List<Integer>>(6);
        searchSingleResultMethod();

        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaEmAberto));           
        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaEmProcesso));
        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaAguardandoCliente));
        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaArguardandoOperadora));
        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaCancelada));
        listPainelControleExtrato.add(Arrays.asList(painelControleExtratoVO.demandaFechamento));

        return LIST;
    }
}

View:

<rich:dataTable                 
                var="painelControleExtrato"  binding="#{table}"
                value="#{painelControleExtratoBean.listPainelControleExtrato}"
                width="100%"
                rows="10"
                onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                border="1" cellspacing="0" cellpadding="2" >

            <f:facet name="header">
                <rich:columnGroup>

                    <rich:column colspan="16" >
                        <h:outputText value="#{painelControleSD.dataAtual}"   />                                
                    </rich:column>  

                    <rich:column breakBefore="true" > 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.servico']}" />
                    </rich:column>

                    <rich:column> 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.emAbertoExtrato']}" />
                    </rich:column>

                    <rich:column> 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.emProcessoEstrato']}" />
                    </rich:column>

                    <rich:column>    
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.aguardandoCliente']}" />
                    </rich:column>

                    <rich:column> 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.aguardandoOperadora']}" />
                    </rich:column>

                    <rich:column> 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.fechado']}" />
                    </rich:column>

                    <rich:column> 
                        <h:outputText value="#{msg['page.formPainelControleExtrato.label.column.cancelado']}" />
                    </rich:column>

                </rich:columnGroup>
            </f:facet>


        </rich:dataTable>

How do I fill my richfaces datatable with a List<List<Integer>>

A B C D
1 3 5 7
8 9 7 3
4 8 9 1

Data in column A refers to vector 1 Data in column B refers to vector 2 Data in column C refers to vector 3

How popular the datatable?

1 answer

1


Create an auxiliary object representing lines:

class ExtratoLinhaVO implements Serializable {
    private Integer demandaEmAberto;
    private Integer demandaEmProcesso;
    // Demais variáveis, getters & setters, etc.

} 

Change your method to create a list of Vos:

public String prepareList() {
    listPainelControleExtrato = new ArrayList<ExtratoLinhaVO>(tamanho);
    for (int i = 0; i < tamanho; i++) {
        final ExtratoLinhaVO linha = new ExtratoLinhaVO();
        linha.setDemandaEmAberto(i < demandaEmAberto.length ? demandaEmAberto[i] : null); 
        linha.setDemandaEmdemandaEmProcesso(i < demandaEmProcesso.length ? demandaEmProcesso[i] : null);
        // Demais parametros
        listPainelControleExtrato.add(linha);
    }

And then use the values normally:

 <rich:column>
     <f:facet name="header">
          <h:outputText value="{msg['page.formPainelControleExtrato.label.column.emAbertoExtrato']}" />
     </f:facet>
     <h:outputText value="#{painelControleExtrato.demandaEmAberto}">
 </rich:column>
 <rich:column>
     <f:facet name="header">
          <h:outputText value="{msg['page.formPainelControleExtrato.label.column.emProcessoExtrato']}" />
     </f:facet>
     <h:outputText value="#{painelControleExtrato.demandaEmProcesso}">
 </rich:column>
 <!-- Demais colunas -->

Browser other questions tagged

You are not signed in. Login or sign up in order to post.