java - JSF + primefaces calling getter way too much times -


i read answers on topic (not only) on so, none of solves problem. have datatable:

<p:datatable                  value="#{reportbean.reportdata.rows}"                 var="row"                  styleclass="listblock datatableoverflowauto fullscreentable"                 rendered="#{!reportbean.reportdata.grouped}">                  <f:facet name="header">                     #{msg['report.table.header']}                 </f:facet>                  <p:column>                     #{row.integrationname}                 </p:column>                  <p:column>                     #{row.integrationid}                 </p:column>                  <p:column>                     #{row.service}                 </p:column>                  <p:columns value="#{reportbean.reportdata.columns}"                            var="column">                       <f:facet name="header">                           #{column}                     </f:facet>                       <h:outputtext value="#{row.getdata(column)}" escape="false" />                   </p:columns> 

getreportdata() on reportbean simple (no calculation):

public reportdatainterface getreportdata() {         return reportdata; } 

and data returned are:

public class nonegroupedreportdata implements reportdatainterface {     private int counter = 0;     logger logger = loggerfactory.getlogger(getclass());     private list<string> columns = new linkedlist<string>();     public void addrow(row row) {         addcolumns(row);     }      public list<string> getcolumns() {         counter++;         logger.debug("getcolumns called {} times", counter);         return columns;     }  .... 

and result

2013-05-15 07:38:07,405 () debug nonegroupedreportdata - getcolumns called 21600 times

for datatable ~30 rows , 10 columns.

i know why jsf calls getters many times, 22k, why? when need more results (>1000) not render in 5 minutes, because endlessly calls getter. problem , how can achieve state in getcolumns() called each row max 5~10 times?

i have tried using jstl c:set "caching" without result (http://qussay.com/2013/04/19/caching-and-reusing-an-evaluated-el-expression-in-jsf/)

edit: guess getter calling not "wrong" sign using datatable in wrong way.

the problem accessing 2 times same data structure,

n: <p:datatable value="#{reportbean.reportdata.rows}" ... 

and inside same p:datatable using

m: <p:columns value="#{reportbean.reportdata.columns}" ... 

that causes n * m product end gives 21600 times, because accessing same data structure in two nested tags...

it not clear kind of datatable trying construct, think should reorganize data structure.

the simpler solution, in case trying put multiple values inside 1 single column each row changing m to:

m: <p:columns value="#{rows.columns}" ... 

but involve changing data structure put columns component rows component.

regards,


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -