Performance when generating a table in JSF

0

I'm having a question about how to improve perfomance when generating a table on a page using components JSF and Primefaces .

I am generating a table, after doing a SQL query and mapping the object using Hibernate , more specifically, creating a list of objects using ResultTransformer interface.

I realize that this is OK, doing TDD, when calling the data the processing is fast.

But it has locked the page when it will generate it.

The page code looks like this:

<c:if test="#{bean.pojo.relatorioExtratoLojista != null}">
    <c:forEach var="loja" items="#{bean.buscarLojas()}">
        <c:forEach var="filial" items="#{bean.buscarFilial(loja)}">
            <c:forEach var="atendente" items="#{bean.buscarAtendente(filial)}">
                <c:forEach var="propostaStatus" items="#{bean.buscarPropostaStatus(atendente)}">
                    <p:panelGrid 
                        styleClass="panelGridCenter gridNoBackground" 
                        style="width: 100%; white-space:nowrap;">
                        <f:facet name="header">
                           // colunas do cabeçalho
                        </f:facet>
                        <c:forEach var="propostaCartao" items="#{bean.buscarPropostasCartao(atendente, propostaStatus)}" varStatus="propostaCartaoVarStatus">
                          // dados da tabela
                        </c:forEach>
                    </p:panelGrid>
                    <br/>
                </c:forEach>
            </c:forEach>
        </c:forEach>
    </c:forEach>

Where I put // colunas do cabeçalho the table header is generated, and the comment // dados da tabela has the table data.

The structure is this:

Map<Loja, Map<Filial, Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>>>> mapLoja 

Some of the methods of the bean are:

public List<Loja> buscarLojas() {
    return new ArrayList<Loja>(this.getPojo().getRelatorioExtratoLojista().keySet());
}

public List<Filial> buscarFilial(Loja loja) {
    Map<Filial, Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>>> mapFilial = this.getPojo().getRelatorioExtratoLojista().get(loja);
    return new ArrayList<Filial>(mapFilial.keySet());
}

public List<Atendente> buscarAtendente(Filial filial) {
    Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>> mapAtendente = this.getPojo().getRelatorioExtratoLojista().
                                                                             get(filial.getLoja()).get(filial);
    return new ArrayList<Atendente>(mapAtendente.keySet());
}

public List<PropostaStatus> buscarPropostaStatus(Atendente atendente) {
    Map<Filial, Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>>> mapFilial = this.getPojo().getRelatorioExtratoLojista().get(atendente.getLoja());
    Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>> mapAtendente = mapFilial.get(atendente.getFilial());
    Map<PropostaStatus, List<PropostaCartao>> mapPropostaStatus = mapAtendente.get(atendente);
    if (NullUtil.isNull(mapPropostaStatus.keySet())) {
        toString();
    }
    return new ArrayList<PropostaStatus>(mapPropostaStatus.keySet());
}

public List<PropostaCartao> buscarPropostasCartao(Atendente atendente, PropostaStatus propostaStatus) {
    Map<Filial, Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>>> mapFilial = this.getPojo().getRelatorioExtratoLojista().get(atendente.getLoja());
    Map<Atendente, Map<PropostaStatus, List<PropostaCartao>>> mapAtendente = mapFilial.get(atendente.getFilial());
    Map<PropostaStatus, List<PropostaCartao>> mapPropostaStatus = mapAtendente.get(atendente);
    return new ArrayList<PropostaCartao>(mapPropostaStatus.get(propostaStatus));
}

When I put it to debugar in bean , I realized that the buscarLojas() method is called many times, apparently more than it should.

I'd like to know what I can do to improve performance, since I've re-set query to just decrease the amount of data.

    
asked by anonymous 09.11.2015 / 17:53

1 answer

2

To formalize an answer.

The main problem in question is the lack of use of LazyLoad and not in select. The rendering of the page, even with purely html element, are able to lock your browser considerably (you can test with tables above 500 lines), in the case of JSF, the result is even worse, since there is still a whole DOM management and an infinite sequence of requests for page building.

Show all the information in a table, which has no fixed amount of results, sooner or later shows a poor architectural choice, since they always tend to grow and generate poor performance not only in the view, but a load on the server.

Adding a page to this list will certainly solve your problem.

    
11.11.2015 / 14:01