2 Replies Latest reply on Jan 12, 2008 7:02 PM by robertocarlos1

    Updating and Rerender

      I have an aplication interface with the tabpanel tag, the interface have 5 tabs. In every tab i have tables, dropdowns, etc. Information is loaded from the database to fill these tags, when i click in one tab i hope that only the controls in that tab should be loaded, and only the methods for get information of these controls should be executed. But in my case all the methods are executed even the methods that get information for fill tags that isn't inside the selected tab

      The most actions inside the tabs rerender only the tab where the button is, there are regions inside every tab and actions are inside it, when i clic in a botton that rise these actions inside the tabs i have the same behavior.

      Is there something that i can do for change this behavior?

      Sorry for the mistakes in my post, im working to improve my english.

      Thanks for your help.

        • 1. Re: Updating and Rerender

          Please provide more info: What RF version, facelets or not and so on. And a code snippet would be great.

          • 2. Re: Updating and Rerender

            I am Using RF 3.1.3. JSF RI 1.2 implementation.

            Here you have the code of the page with tabs

            <?xml version="1.0" encoding="UTF-8"?>
            <div style="with:100%" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
             <f:subview id="pfSuscripcionesSolicitud">
             <h:form>
             <a4j:region>
             <h:panelGrid columns="1" columnClasses="tableRow" width="100%">
             <a4j:outputPanel id="mantPanel">
             <h:panelGrid cellpadding="0" cellspacing="5" columns="4" width="100%">
             ................
             ................
             <h:outputLabel for="plazo" value="Plazo:"/>
             <h:selectOneMenu binding="#{pfSuscripcionesSolicitud.plazo}" id="plazo" style="width: 300px">
             <f:converter converterId="javax.faces.Long"/>
             <f:selectItems value="#{pfSuscripcionesSolicitud.plazosList}"/>
             <a4j:support reRender="idplan,idseguro,terminalid,cuotaactivacion,tomarseguro,mesescobertura" limitToList="true" event="onchange" ajaxSingle="true">
             </a4j:support>
             </h:selectOneMenu>
             <h:outputLabel for="idcondicion" value="Condicion:"/>
             <h:selectOneMenu binding="#{pfSuscripcionesSolicitud.idcondicion}" id="idcondicion" style="width: 200px">
             <f:converter converterId="javax.faces.Long"/>
             <f:selectItems value="#{pfSuscripcionesSolicitud.condicionesList}"/>
             <a4j:support reRender="idplan,idseguro,terminalid,cuotaactivacion,tomarseguro,mesescobertura" limitToList="true" event="onchange" ajaxSingle="true">
             </a4j:support>
             </h:selectOneMenu>
             <h:outputLabel for="idplan" value="Plan:"/>
             <h:selectOneMenu binding="#{pfSuscripcionesSolicitud.idplan}" id="idplan" style="width: 300px">
             <f:converter converterId="javax.faces.Long"/>
             <f:selectItems value="#{pfSuscripcionesSolicitud.planesList}"/>
             <a4j:support reRender="idplan,idseguro,terminalid,cuotaactivacion,tomarseguro,mesescobertura" limitToList="true" event="onchange" ajaxSingle="true">
             </a4j:support>
             </h:selectOneMenu>
             <h:outputLabel for="terminalid" value="Terminal:"/>
             <h:selectOneMenu id="terminalid" binding="#{pfSuscripcionesSolicitud.terminalid}" style="width: 300px">
             <f:converter converterId="javax.faces.Long"/>
             <f:selectItems value="#{pfSuscripcionesSolicitud.terminalesList}"/>
             <a4j:support reRender="idplan,idseguro,terminalid,cuotaactivacion,tomarseguro,mesescobertura" limitToList="true" event="onchange" ajaxSingle="true">
             </a4j:support>
             </h:selectOneMenu>
             <h:outputLabel for="tomarseguro" value="Tomar Seguro:"/>
             <h:selectBooleanCheckbox id="tomarseguro" binding="#{pfSuscripcionesSolicitud.tomarseguro}" style="width: 150px" />
             <h:outputLabel for="idseguro" value="Seguro:"/>
             <h:selectOneMenu id="idseguro" binding="#{pfSuscripcionesSolicitud.idseguro}" style="width: 150px">
             <f:converter converterId="javax.faces.Long"/>
             <f:selectItems value="#{pfSuscripcionesSolicitud.segurosList}"/>
             </h:selectOneMenu>
             <h:outputLabel for="mesescobertura" value="Meses Cobertura:"/>
             <h:inputText binding="#{pfSuscripcionesSolicitud.mesescobertura}" id="mesescobertura" style="width: 288px" >
             <f:converter converterId="javax.faces.BigDecimal"/>
             </h:inputText>
             <h:outputLabel for="cuotaactivacion" value="Cuota Activacion:"/>
             <h:inputText binding="#{pfSuscripcionesSolicitud.cuotaactivacion}" id="cuotaactivacion" style="width: 288px" >
             <f:converter converterId="javax.faces.BigDecimal"/>
             </h:inputText>
             <h:outputLabel for="tir" value="TIR: "/>
             <h:inputText binding="#{pfSuscripcionesSolicitud.tir}" id="tir" style="width: 150px" >
             <f:converter converterId="javax.faces.BigDecimal"/>
             </h:inputText>
             <h:outputLabel for="awn" value="AWN: "/>
             <h:inputText binding="#{pfSuscripcionesSolicitud.awn}" id="awn" style="width: 150px" >
             <f:converter converterId="javax.faces.BigDecimal"/>
             </h:inputText>
             </h:panelGrid>
             <h:panelGrid columns="2">
             <a4j:commandButton reRender="mantPanel,suscripcionesListPannel,action,idsuscripcion" value="#{pfSuscripcionesSolicitud.suscripcionesCommandValue}" actionListener="#{pfSuscripcionesSolicitud.adicionaroActualizar}"/>
             <a4j:commandButton reRender="mantPanel,action,idsuscripcion,serviciosAuxPanel" value="Crear Nuevo" rendered="#{pfSuscripcionesSolicitud.modifyingSuscripciones}" actionListener="#{pfSuscripcionesSolicitud.clear}"/>
             </h:panelGrid>
             </a4j:outputPanel>
             </h:panelGrid>
             <rich:separator lineType="solid" height="2"/>
             <a4j:outputPanel id="suscripcionesListPannel">
             <rich:dataTable width="100%" id="suscripcionesTable" binding="#{pfSuscripcionesSolicitud.suscripcionesTable}" value="#{pfSuscripcionesSolicitud.suscripcionesList}" rows="10" columnClasses="col" var="suscripcion" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'">
             <!-- onRowClick="this.style.backgroundColor='#F1F1F1'" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor='' -->
             <f:facet name="header">
             <rich:columnGroup>
             <h:column>
             .....................
             .....................
             <h:outputText styleClass="headerText"/>
             </h:column>
             <h:column>
             <h:outputText styleClass="headerText"/>
             </h:column>
             </rich:columnGroup>
             </f:facet>
             ...................
             ..................
            
             <h:column>
             <a4j:commandButton reRender="mantPanel,action,idsuscripcion,serviciosAuxPanel" image="/../../resources/images/oTasks.gif" id="selectButton" actionListener="#{pfSuscripcionesSolicitud.selectRow}">
             </a4j:commandButton>
             </h:column>
             <h:column>
             <a4j:commandButton reRender="mantPanel,suscripcionesListPannel,action,idsuscripcion,serviciosAuxPanel" image="/../resources/images/delete.gif" id="deleteButton" actionListener="#{pfSuscripcionesSolicitud.deleteRow}">
             </a4j:commandButton>
             </h:column>
             </rich:dataTable>
             </a4j:outputPanel>
             <h:inputHidden id="idsolicitud" binding="#{pfSuscripcionesSolicitud.idsolicitud}">
             <f:converter converterId="javax.faces.Long"/>
             </h:inputHidden>
             <h:inputHidden id="action" binding="#{pfSuscripcionesSolicitud.action}">
             <f:converter converterId="javax.faces.Integer"/>
             </h:inputHidden>
             <h:inputHidden id="idsuscripcion" binding="#{pfSuscripcionesSolicitud.idsuscripcion}">
             <f:converter converterId="javax.faces.Long"/>
             </h:inputHidden>
             <h:inputHidden id="suscripcionrenovar" binding="#{pfSuscripcionesSolicitud.suscripcionrenovar}">
             <f:converter converterId="javax.faces.Long"/>
             </h:inputHidden>
             </a4j:region>
             </h:form>
             </f:subview>
            </div>
            


            here you the code of the backing bean

            package sv.com.digicel.spp2.web.managedbeans.solicitud;
            
            import javax.faces.component.html.HtmlInputText;
            import javax.faces.component.html.HtmlSelectBooleanCheckbox;
            import javax.faces.component.html.HtmlSelectOneMenu;
            import org.richfaces.component.html.HtmlDataTable;
            import javax.faces.component.html.HtmlInputHidden;
            import java.util.List;
            import java.util.ArrayList;
            import sv.com.digicel.spp2.bussiness.client.catalogos.PlazoscontratoDelegate;
            import sv.com.digicel.spp2.bussiness.client.solicitud.PlazospostpagoDelegate;
            import sv.com.digicel.spp2.bussiness.client.catalogos.CondicionesDelegate;
            import sv.com.digicel.spp2.bussiness.client.ProductosDelegate;
            import java.util.Iterator;
            import sv.com.digicel.spp2.bussiness.catalogos.cmps.Plazoscontrato;
            import javax.faces.model.SelectItem;
            import sv.com.digicel.spp2.bussiness.catalogos.cmps.Condiciones;
            import java.math.BigDecimal;
            import sv.com.digicel.spp2.web.commons.Actions;
            import javax.faces.event.ActionEvent;
            import sv.com.digicel.spp2.bussiness.cmps.productos.Productos;
            import sv.com.digicel.spp2.bussiness.productos.cmps.Plazospostpago;
            import sv.com.digicel.spp2.bussiness.client.solicitud.SuscripcionesSolicitudDelegate;
            import sv.com.digicel.spp2.bussiness.solicitud.cmps.SuscripcionesSolicitud;
            import sv.com.digicel.spp2.web.managedbeans.cuentas.PfServiciosSuscripciones;
            import sv.com.digicel.spp2.web.managedbeans.common.PfBase;
            import javax.persistence.NoResultException;
            import sv.com.digicel.spp2.web.managedbeans.cuentas.PfServiciosAuxiliaresSuscripciones;
            
            public class PfSuscripcionesSolicitud extends PfBase {
             private HtmlInputText cantidad = new HtmlInputText();
             private HtmlInputText mesescobertura = new HtmlInputText();
             private HtmlInputText cuotaactivacion = new HtmlInputText();
             private HtmlInputText tir = new HtmlInputText();
             private HtmlInputText awn = new HtmlInputText();
             private HtmlSelectBooleanCheckbox tomarseguro = new HtmlSelectBooleanCheckbox();
             private HtmlSelectOneMenu plazo = new HtmlSelectOneMenu();
             private HtmlSelectOneMenu idcondicion = new HtmlSelectOneMenu();
             private HtmlSelectOneMenu idplan = new HtmlSelectOneMenu();
             private HtmlSelectOneMenu terminalid = new HtmlSelectOneMenu();
             private HtmlSelectOneMenu idseguro = new HtmlSelectOneMenu();
             private HtmlInputHidden idsolicitud = new HtmlInputHidden();
             private HtmlInputHidden action = new HtmlInputHidden();
             private HtmlInputHidden idsuscripcion = new HtmlInputHidden();
             private HtmlInputHidden suscripcionrenovar = new HtmlInputHidden();
             private HtmlDataTable suscripcionesTable = new HtmlDataTable();
             private List suscripcionesList = new ArrayList();
             private List plazosList = new ArrayList();
             private List condicionesList = new ArrayList();
             private List planesList = new ArrayList();
             private List terminalesList = new ArrayList();
             private List segurosList = new ArrayList();
             private CondicionesDelegate condicionesDel = null;
             private PlazospostpagoDelegate plazosPostDel = null;
             private PlazoscontratoDelegate plazosContratoDel = null;
             private ProductosDelegate prodDel = null;
             private SuscripcionesSolicitudDelegate suscSolDel = null;
            
             private CondicionesDelegate getCondicionesDel(){
             if (condicionesDel == null){
             condicionesDel = new CondicionesDelegate();
             }
             return condicionesDel;
             }
            
             private PlazospostpagoDelegate getPlazosPostDel(){
             if (plazosPostDel == null){
             plazosPostDel = new PlazospostpagoDelegate();
             }
             return plazosPostDel;
             }
            
             private PlazoscontratoDelegate getPlazosContratoDel(){
             if (plazosContratoDel == null){
             plazosContratoDel = new PlazoscontratoDelegate();
             }
             return plazosContratoDel;
             }
            
             private ProductosDelegate getProdDel(){
             if (prodDel == null){
             prodDel = new ProductosDelegate();
             }
             return prodDel;
             }
            
             private SuscripcionesSolicitudDelegate getSuscSolDel(){
             if (suscSolDel==null){
             suscSolDel = new SuscripcionesSolicitudDelegate();
             }
             return suscSolDel;
             }
            
            
             private void fillPlazos(){
             //Load the information from database
             }
            
             private void fillCondiciones(){
             //Load information from database
             }
            
             private void fillPlanes(){
             //load the information from database
             }
            
             public void fillTerminales(){
             //load the information from the database...
            
             }
            
             ......
             ......
             ......
             public List getPlanesList() {
             if (this.planesList.isEmpty()){
             this.fillPlanes();
             }
             return planesList;
             }
            
             public HtmlSelectOneMenu getPlazo() {
             return plazo;
             }
            
             public List getPlazosList() {
             if (this.plazosList.isEmpty()){
             this.fillPlazos();
             }
             return plazosList;
             }
            
             public List getSegurosList() {
             if (this.segurosList.isEmpty()){
             this.fillSeguros();
             }
             return segurosList;
             }
            
             public List getSuscripcionesList() {
             if (this.suscripcionesList.isEmpty()){
             this.suscripcionesList = this.getSuscSolDel().findByIdsolicitud((Long)this.getIdsolicitud().getValue());
             }
             return suscripcionesList;
             }
            
             public void setIdsolicitud(Long idsolicitud){
             this.getIdsolicitud().setValue(idsolicitud);
             this.suscripcionesList = this.getSuscSolDel().findByIdsolicitud(idsolicitud);
             PfServiciosSuscripciones pfServiciosSuscripciones = (PfServiciosSuscripciones) this.getBean("pfServiciosSuscripciones");
             pfServiciosSuscripciones.setIdsolicitud(idsolicitud);
             }
            
             public HtmlDataTable getSuscripcionesTable() {
             return suscripcionesTable;
             }
            
             public HtmlInputHidden getSuscripcionrenovar() {
             return suscripcionrenovar;
             }
            
             public List getTerminalesList() {
             if (this.terminalesList.isEmpty()){
             fillTerminales();
             }
             return terminalesList;
             }
            
             public HtmlSelectOneMenu getTerminalid() {
             return terminalid;
             }
            
             public HtmlInputText getTir() {
             return tir;
             }
            
             public HtmlSelectBooleanCheckbox getTomarseguro() {
             return tomarseguro;
             }
            
             public String getSuscripcionesCommandValue(){
             if (this.isModifyingSuscripciones()){
             return "Actualizar";
             }else{
             return "Adicionar";
             }
             }
            
             public void fillSeguros(){
             //Load the information from the databases
             }
            
             public void setSelectedRow(SuscripcionesSolicitud suscripciones){
             this.getAction().setValue(Actions.ACTION_UPDATE.ordinal());
             this.getAwn().setValue(suscripciones.getAwn());
             this.getCantidad().setValue(suscripciones.getNumerodelineas());
             this.getCuotaactivacion().setValue(suscripciones.getPrecioactivacion());
             this.getIdcondicion().setValue(suscripciones.getIdcondicion());
             this.getPlazo().setValue(suscripciones.getMesescontrato());
             this.fillPlanes();
             this.getIdplan().setValue(suscripciones.getIdplan());
             this.fillTerminales();
             this.getTerminalid().setValue(suscripciones.getTerminalid());
             this.fillSeguros();
             this.getIdseguro().setValue(suscripciones.getIdseguro());
             this.getIdsuscripcion().setValue(suscripciones.getIdsuscripcion());
             this.getTir().setValue(suscripciones.getTir());
             this.getTomarseguro().setValue(new BigDecimal(1).equals(suscripciones.getTomarseguro())?Boolean.TRUE:Boolean.FALSE);
             PfServiciosSuscripciones pfServiciosSuscripciones = (PfServiciosSuscripciones) this.getBean("pfServiciosSuscripciones");
             pfServiciosSuscripciones.setIdsolicitudAndIdsuscripcion(suscripciones.getIdsolicitud(), suscripciones.getIdsuscripcion());
             PfServiciosAuxiliaresSuscripciones pfserviciosAux = (PfServiciosAuxiliaresSuscripciones) this.getBean("pfServiciosAuxiliaresSuscripciones");
             pfserviciosAux.setIdsolicitudAndIdsuscripcion(suscripciones.getIdsolicitud(), suscripciones.getIdsuscripcion());
             }
            
             public void selectRow(ActionEvent ae){
             System.out.println("selectRow >>>>>>>>>>>>>>>>>");
             SuscripcionesSolicitud suscripciones = (SuscripcionesSolicitud) this.getSuscripcionesTable().getRowData();
             setSelectedRow(suscripciones);
             }
            
             public void clear(){
             this.getAction().setValue(Actions.ACTION_NEW.ordinal());
             this.getAwn().setValue(null);
             this.getCantidad().setValue(null);
             this.getCuotaactivacion().setValue(null);
             this.getIdcondicion().setValue(null);
             this.getPlazo().setValue(null);
             fillPlanes();
             this.getIdplan().setValue(null);
             fillTerminales();
             fillSeguros();
             this.getIdseguro().setValue(null);
             this.getIdsuscripcion().setValue(null);
             this.getMesescobertura().setValue(null);
             this.getSuscripcionrenovar().setValue(null);
             this.getTerminalid().setValue(null);
             this.getTir().setValue(null);
             this.getTomarseguro().setValue(null);
             PfServiciosSuscripciones pfServiciosSuscripciones = (PfServiciosSuscripciones) this.getBean("pfServiciosSuscripciones");
             pfServiciosSuscripciones.clear();
             PfServiciosAuxiliaresSuscripciones pfserviciosAux = (PfServiciosAuxiliaresSuscripciones) this.getBean("pfServiciosAuxiliaresSuscripciones");
             pfserviciosAux.clear();
             }
            
             public void deleteRow(ActionEvent ae){
             SuscripcionesSolicitud suscripciones = (SuscripcionesSolicitud) this.getSuscripcionesTable().getRowData();
             PfServiciosSuscripciones pfServiciosSuscripciones = (PfServiciosSuscripciones) this.getBean("pfServiciosSuscripciones");
             pfServiciosSuscripciones.removeServices();
             this.getSuscSolDel().delete(suscripciones.getIdsuscripcion());
             this.suscripcionesList = this.getSuscSolDel().findByIdsolicitud((Long)this.getIdsolicitud().getValue());
             clear();
             }
            
             private SuscripcionesSolicitud fillSuscripciones(){
             // Create and fill the information that is send to the server for create or update
             }
            
             public void adicionaroActualizar(ActionEvent ae){
             SuscripcionesSolicitudDelegate suscDel = this.getSuscSolDel();
             SuscripcionesSolicitud suscSol = this.fillSuscripciones();
             PfServiciosSuscripciones pfServiciosSuscripciones = (PfServiciosSuscripciones) this.getBean("pfServiciosSuscripciones");
             System.out.println("Action: "+this.getAction().getValue());
             if (new Integer(Actions.ACTION_NEW.ordinal()).equals(this.getAction().getValue())){
             suscSol = suscDel.insert(suscSol);
             this.getIdsuscripcion().setValue(suscSol.getIdsuscripcion());
             System.out.println("Inserting: "+this.getAction().getValue());
             pfServiciosSuscripciones.getIdsuscripcion().setValue(suscSol.getIdsuscripcion());
             pfServiciosSuscripciones.saveSelected();
             }else{
             System.out.println(suscSol.getIdsuscripcion());
             suscDel.update(suscSol);
             pfServiciosSuscripciones.saveSelected();
             System.out.println("Updating: "+this.getAction().getValue());
             }
             this.suscripcionesList = suscDel.findByIdsolicitud((Long)this.getIdsolicitud().getValue());
             this.getAction().setValue(Actions.ACTION_UPDATE.ordinal());
             }
            
             public boolean isModifyingSuscripciones(){
             return new Integer(Actions.ACTION_UPDATE.ordinal()).equals(this.getAction().getValue());
             }
            
             public void clear(ActionEvent ae){
             this.clear();
             }
            }
            


            I have some fragments and a main page where every fragment required are included, the code above is of one of seven fragments, all the fragments are similars.

            When an action is raised the phases of the JSF are executed and the methods get for all the controls in the pages are executed too. I have the code for loading the information from the database in the get methods of the property that contain the datamodel, Like you see in the code of the backing bean.

            Thanks for your help.