Hi everybody i have an implementation of the DataModel in my application, for load my dataTables using lazy load. I find the implementation of the DataModel in this link:
http://wiki.apache.org/myfaces/WorkingWithLargeTables WorkingWithLargeTables in this reference the load of the data (the acces to the DB) is in a method get and can see in the debug that this method is executed more that one time in every call to the datascroller for the framework. I have a button that make a submit and when y make click in this the calls to the method get are more. I am so worried about this because this model is too much ineficient, and the connections to the database are too much. private DataPage<SomeRowObject> getDataPage(int startRow, int pageSize) { // access database here, or call EJB to do so } Conclusion: I wanna know how i a can optimize this because is not logic that i need acces de data base more than one time for every request. I hope an response, and one light to my problem. Thaks so much for you time, best regards This is the code of my maneged Bean <t:dataTable id="tabla_listaCanales" var="item" rows="10" width="100%" value="#{backing_Administracion_Canales_TablaPaginada.dataModel}"> <f:facet name="header"> <t:columnGroup> <t:column><h:outputText value="NOMBRE CANAL"/></t:column> <t:column><h:outputText value="ESTADO DEL CANAL"/></t:column> </t:columnGroup> </f:facet> <t:column> <h:outputText value="#{item.strNombreComercialCanal}"/> </t:column> <t:column> <h:outputText value="#{item.strDsEstadoCanal}"/> </t:column> </t:dataTable> <br /><br /><br /> <t:datascroller for="tabla_listaCanales" maxPages="5" binding="#{backing_Administracion_Canales_TablaPaginada.paginador}" reRender="estiloCebra" /> This is the code of mi menaged bean: public class TablaPaginada { private transient PagedListDataModel dataModel; private transient HtmlDatascroller paginador; private String strNombreCanal; private List<ItemTabla> lista_canales = new LinkedList<ItemTabla>(); ItemTabla arrayCanales[] = {new ItemTabla("Canal 1", "habilitado"), new ItemTabla("Canal 2", "bloqueado"), new ItemTabla("Canal 3", "habilitado"), new ItemTabla("Canal 4", "deshabilitado"), new ItemTabla("Canal 5", "bloqueado"), new ItemTabla("Canal 6", "habilitado"), new ItemTabla("Canal 7", "deshabilitado"), new ItemTabla("Canal 8", "habilitado"), new ItemTabla("Canal 9", "habilitado"), new ItemTabla("Canal 10", "habilitado"), new ItemTabla("Canal 11", "habilitado"), new ItemTabla("Canal 12", "deshabilitado"), new ItemTabla("Canal 13", "habilitado"), new ItemTabla("Canal 14", "habilitado"), new ItemTabla("Canal 15", "deshabilitado"), new ItemTabla("Canal 16", "bloqueado")}; public TablaPaginada() { HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); strNombreCanal = request.getParameter("campo_nombreCanal"); } private DataPage<ItemTabla> getDataPage(int startRow, int pageSize) { int nmRowCount = arrayCanales.length; if(lista_canales != null) { System.out.println("Obtencion de los datos de la tabla"); int nmFin; if((startRow + pageSize) < arrayCanales.length) { nmFin = (startRow + pageSize - 1); } else { nmFin = arrayCanales.length; } lista_canales = new LinkedList<ItemTabla>(); for(int a=startRow; a<nmFin; a++) { lista_canales.add(arrayCanales[a]); } } return new DataPage<ItemTabla>(nmRowCount, startRow, lista_canales); } public void action_consultar(ActionEvent event) { event = null; paginador.setPage(paginador.FIRST_FACET_NAME); } public DataModel getDataModel() { if (dataModel == null) { dataModel = new LocalDataModel(5); } return dataModel; } public void setStrNombreCanal(String strNombreCanal) { this.strNombreCanal = strNombreCanal; } public String getStrNombreCanal() { return strNombreCanal; } public void setPaginador(HtmlDatascroller paginador) { this.paginador = paginador; } public HtmlDatascroller getPaginador() { return paginador; } private class LocalDataModel extends PagedListDataModel { public LocalDataModel(int pageSize) { super(pageSize); } public DataPage<ItemTabla> fetchPage(int startRow, int pageSize) { // call enclosing managed bean method to fetch the data return getDataPage(startRow, pageSize); } } } -- View this message in context: http://www.nabble.com/DataModel-problem-with-multiple-access-to-the-DataBase-tp18120402p18120402.html Sent from the My Faces - Dev mailing list archive at Nabble.com.
