5 Replies Latest reply on Jul 26, 2013 9:02 PM by Paul Baker

    Data Table Not reRendering after form submit.

    Mik Cantrell Newbie

      I have a simple rich:datatable.  I have it setup to accept a variable and on blur submit that variable to a bean that runs an oracle query and it should rerender the datatable after that. It does get to the action method on my backing bean and runs the query but it does not refresh/rerender my datatable.  Been looking at this for over a day now and would appreciate any help or advice.  I have read many discussions but none have helped me.

       

      Tomcat 7

      RichFaces 4.3.3

       

      --------------------------------

      Libs

      activation.jar

      antlr-2.7.6.jar

      asm.jar

      asm-attrs.jar

      cglib-2.1.3.jar

      commons-beanutils-1.8.3.jar

      commons-collections-3.2.jar

      commons-digester-1.8.jar

      commons-fileupload.jar

      commons-io.jar

      commons-lang.jar

      commons-logging-1.1.1.jar

      cssparser-0.9.5.jar

      dom4j-1.6.1.jar

      el-api-2.2.1-b03.jar

      FastInfoset.jar

      guava-14.0.1.jar

      hibernate3.jar

      hibernate-jpa-2.0-api-1.0.1.Final.jar

      icefaces.jar

      icefaces-ace.jar

      icefaces-compat.jar

      icepush.jar

      javassist-3.12.0.GA.jar

      javax.annotation.jar

      javax.servlet.jsp.jstl-1.2.1.jar

      javax.servlet.jsp.jstl-api-1.2.1.jar

      jboss-el-2.0.0.GA.jar

      jsf-api-2.1.3-b02.jar

      jsf-impl-2.1.3-b02.jar

      jsr305-1.3.9.jar

      jsr305-1.3.9.jar

      jta-1.1.jar

      log4j.jar

      myfaces-api-2.1.12.jar

      myfaces-impl-2.1.12.jarr

      myfaces-bundle-2.1.12.jar

      ojdbc6.jar

      oscache-2.1.jar

      poi-3.7.jar

      richfaces-archetype-kitchensink.jar

      richfaces-archetype-simpleapp.jar

      richfaces-components-api-4.3.3.Final.jar

      richfaces-components-ui-4.3.3.Final.jar

      richfaces-core-api-4.3.3.Final.jar

      richfaces-core-impl-4.3.3.Final.jar

      sac-1.3.jar

      slf4j-api-1.6.1.jar

      util-bridges.jar

      util-java.jarutil-taglib.jar

       

      ----------------------------------------

       

       

      PAGE

      <?xml version="1.0"?>

       

      <faces-config

          version="2.0"

          xmlns="http://java.sun.com/xml/ns/javaee"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"

      >

          <managed-bean>

              <managed-bean-name>MCGContentFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MCGContentFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <managed-bean>

              <managed-bean-name>MCGGenesFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MCGGenesFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <managed-bean>

              <managed-bean-name>MCGDiagnosesFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MCGDiagnosesFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <managed-bean>

              <managed-bean-name>MutationsFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MutationsFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <managed-bean>

              <managed-bean-name>MVCountsFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MVCountsFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <managed-bean>

              <managed-bean-name>MCGProtocolsFrm</managed-bean-name>

              <managed-bean-class>edu.mcg.common.app.beans.MCGProtocolsFrm</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

          </managed-bean>

          <lifecycle>

              <phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>

             

          </lifecycle>

      </faces-config>

       

       

       

      ----------------------------

      BACKING BEAN

      package edu.mcg.common.app.beans;

       

      import java.util.ArrayList;

      import java.util.List;

      import javax.faces.model.SelectItem;

      import edu.mcg.common.formBeans.MCGProtocolsFB;

      import org.richfaces.model.Filter;

       

       

      public class MCGProtocolsFrm

      {

          MCGProtocolsFB fb = new MCGProtocolsFB();

          private String mcgpIdSF = "";

          private String nctIdSF = "";

          private String statusSF = "";

          private String titleSF = "";

          private String phasesSF = "";

       

          private List<SelectItem> suggLst = new ArrayList<SelectItem>();

          private List<MCGProtocolsFB> lst = new ArrayList<MCGProtocolsFB>();

       

          public synchronized List<MCGProtocolsFB> getLst()

          {

              this.lst = new ArrayList();

              String sqlWhere = " ROWNUM < 500 ";

             

              fb = new MCGProtocolsFB();

       

              if (!this.mcgpIdSF.equals(""))

              {

                  sqlWhere = sqlWhere + " AND mcgp_id = '" + this.getMcgpIdSF() + "'";

              }

             

              if (!this.nctIdSF.equals(""))

              {

                  sqlWhere = sqlWhere + " AND nct_id = '" + this.getNctIdSF() + "'";

              }

       

              if (!this.statusSF.equals(""))

              {

                  sqlWhere = sqlWhere + " AND status LIKE '%" + this.getStatusSF() + "%'";

              }

             

              if (!this.titleSF.equals(""))

              {

                  sqlWhere = sqlWhere + " AND title LIKE '%" + this.getTitleSF() + "%'";

              }

       

             

              if (!this.phasesSF.equals(""))

              {

                  sqlWhere = sqlWhere + " AND phases LIKE '%" + this.getPhasesSF() + "%'";

              }

       

              fb.setSqlWhere(sqlWhere);

              fb.setList();

              lst = fb.getList();

             

              return lst;

          }

       

          public synchronized void setLst(List<MCGProtocolsFB> lst)

          {

         

              this.lst = lst;

          }

       

          public List<SelectItem> getSuggLst()

          {

              if (suggLst == null || suggLst.size() == 0)

              {

                  setSuggLst();

              }

       

              return suggLst;

          }

       

          public void setSuggLst()

          {

              suggLst = new ArrayList<SelectItem>();

             

              if (suggLst != null)

              {

                  suggLst.clear();

              }

             

              SelectItem item = new SelectItem("", "");

              suggLst.add(item);

       

              //suggLst = new ArrayList<String>();

             

              MCGProtocolsFB fb = new MCGProtocolsFB();

              fb.setSqlOrdBy("mcgp_id");

              fb.setList();

             

              for (int i = 0; i < fb.getList().size(); i++)

              {

                  MCGProtocolsFB fb2 = new MCGProtocolsFB();

                  fb2 = (MCGProtocolsFB) fb.getList().get(i);

                  item = new SelectItem(fb2.getMcgpIdSF(), fb2.getNctIdSF() + " " + fb2.getTitleSF());

       

                  suggLst.add(item);

              }

          }

         

       

          public synchronized String getMcgpIdSF()

          {

      /*        fb = new MCGProtocolsFB();

              fb.setMcgpIdSF(this.mcgpIdSF);

              fb.setList();

      */        return mcgpIdSF;

          }

       

          public synchronized void setMcgpIdSF(String mcgpIdSF)

          {

      //        System.out.println("\nMIK IN SET MCGPIF = " + this.mcgpIdSF);

      //        fb.setMcgpIdSF(this.mcgpIdSF);

      //        fb.setList();

              this.mcgpIdSF = mcgpIdSF;

          }

       

         

          public synchronized void filter()

          {

              System.out.println("\nMIK IN SET MCGPIF = " + this.mcgpIdSF);

      //        fb.setMcgpIdSF(this.mcgpIdSF);

      //        fb.setList();

          }

         

          public synchronized String getNctIdSF()

          {

              return nctIdSF;

          }

       

          public synchronized void setNctIdSF(String nctIdSF) {

              this.nctIdSF = nctIdSF;

          }

       

          public synchronized String getStatusSF() {

              return statusSF;

          }

       

          public synchronized void setStatusSF(String statusSF) {

              this.statusSF = statusSF;

          }

       

          public synchronized String getTitleSF() {

              return titleSF;

          }

       

          public synchronized void setTitleSF(String titleSF) {

              this.titleSF = titleSF;

          }

       

          public synchronized String getPhasesSF() {

              return phasesSF;

          }

       

          public synchronized void setPhasesSF(String phasesSF) {

              this.phasesSF = phasesSF;

          }

      }

       

      -----------------------------------------

       

      SQL OUTPUT FROM HIBERNATE

       

      MIK IN SET MCGPIF = CDR0000749229

      Hibernate: select mcgprotoco0_.mcgp_id as mcgp1_5_, mcgprotoco0_.nct_id as nct2_5_, mcgprotoco0_.title as title5_, mcgprotoco0_.status as status5_, mcgprotoco0_.phases as phases5_ from mcg_protocols_mv mcgprotoco0_ where 1=1 and ROWNUM<500 and mcgp_id='CDR0000749229'

       

       

      -----------------------------------

       

      VISUAL OF DATATABLE

        • 1. Re: Data Table Not reRendering after form submit.
          Paul Baker Apprentice

          Please post a snippit of the rich:datatable.

          ...and FYI - The visual of the DataTable is not displaying (for me)..

          • 3. Re: Data Table Not reRendering after form submit.
            Paul Baker Apprentice

            Hi Mike,

            I meant a snippet of the rich:datatable. To be clearer... please post the complete rich:datatable componet.

             

            Like this:

             

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
                <rich:dataTable width="700" var="record" value="#{reportBean.expReport.records}">
                    <f:facet name="header">
                        <rich:columnGroup>
                            <rich:column rowspan="2">
                            </rich:column>
                            <rich:column colspan="3">
                                <h:outputText value="Expenses" />
                            </rich:column>
                            <rich:column rowspan="2">
                                <h:outputText value="subtotals" />
                            </rich:column>
                            <rich:column breakRowBefore="true">
                                <h:outputText value="Meals" />
                            </rich:column>
                            <rich:column>
                                <h:outputText value="Hotels" />
                            </rich:column>
                            <rich:column>
                                <h:outputText value="Transport" />
                            </rich:column>
                        </rich:columnGroup>
                    </f:facet>
             
                    <rich:column colspan="5">
                        <h:outputText value="#{record.city}" />
                    </rich:column>
            bla bla bla
            

             

             

            • 4. Re: Data Table Not reRendering after form submit.
              Mik Cantrell Newbie

              <?xml version="1.0" encoding="UTF-8"?>

              <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                              xmlns:a4j="http://richfaces.org/a4j"

                              xmlns:aui="http://liferay.com/faces/aui"

                              xmlns:c="http://java.sun.com/jsp/jstl/core"

                              xmlns:f="http://java.sun.com/jsf/core"

                              xmlns:h="http://java.sun.com/jsf/html"

                              xmlns:bridge="http://liferay.com/faces/bridge"

                              xmlns:rich="http://richfaces.org/rich"

                              xmlns:ui="http://java.sun.com/jsf/facelets"

                              xmlns:fn="http://java.sun.com/jsp/jstl/functions"

                              xmlns:ace="http://www.icefaces.org/icefaces/components"

                              xmlns:ice="http://www.icesoft.com/icefaces/component"

              >

              <h:head>

              </h:head>

               

              <h:body>

              <h:form>

                  <rich:messages/>

                      <rich:dataTable width="100%" value="#{MCGProtocolsFrm.lst}" var="lst" id="table" rows="50">

                  <f:facet name="noData">

                              No Data Found

                          </f:facet>

               

               

                      <rich:column>

                          <f:facet name="header">

                                 <h:outputText value="#{i18n['MCGProts.protID']}"/>

                                      <h:inputText id="mcgpIDSF" value="#{MCGProtocolsFrm.mcgpIdSF}">

                                          <a4j:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" execute="@all" />

                                      </h:inputText>

                          </f:facet>

                          <h:outputText styleClass="columnLeft" value="#{lst.mcgpIdSF}" />

                      </rich:column>

                      <rich:column >

                          <f:facet name="header">

                              <h:outputText value="#{i18n['MCGProts.nctID']}" />

                                  <h:inputText id="nctIDSF" value="#{MCGProtocolsFrm.nctIdSF}">

                                      <f:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" />

                                  </h:inputText>

                           </f:facet>

                               <h:outputText styleClass="columnCenter" value="#{lst.nctIdSF}"/>

                       </rich:column>

                      <rich:column >

                          <f:facet name="header">

                              <h:outputText value="#{i18n['MCGProts.status']}" />

                                  <h:inputText id="statusSF" value="#{MCGProtocolsFrm.statusSF}">

                                      <f:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" />

                                  </h:inputText>

                           </f:facet>

                               <h:outputText styleClass="columnCenter" value="#{lst.statusSF}"/>

                       </rich:column>

                      <rich:column >

                          <f:facet name="header">

                              <h:outputText value="#{i18n['MCGProts.title']}" />

                                  <h:inputText size="100" id="titleSF" value="#{MCGProtocolsFrm.titleSF}">

                                      <f:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" />

                                   </h:inputText>

                           </f:facet>

                               <h:outputText styleClass="columnCenter" value="#{lst.titleSF}"/>

                       </rich:column>

                      <rich:column >

                          <f:facet name="header">

                              <h:outputText value="#{i18n['MCGProts.phases']}" />

                                  <h:inputText id="phasesSF" value="#{MCGProtocolsFrm.phasesSF}">

                                      <f:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" />

                                  </h:inputText>

                           </f:facet>

                               <h:outputText styleClass="columnCenter" value="#{lst.phasesSF}"/>

                       </rich:column>

                    

                  </rich:dataTable>

                  </h:form>    

                      </h:body>

              </ui:composition>

              • 5. Re: Data Table Not reRendering after form submit.
                Paul Baker Apprentice

                You only have the execute attribute on the first filter.. Try adding execute="@this" to each filter

                <f:ajax event="blur" listener="#{MCGProtocolsFrm.filter}" render="table" execute="@this"/>

                @Update -

                I also see that your filter method has the key lines commented out..

                   public synchronized void filter()

                    {

                        System.out.println("\nMIK IN SET MCGPIF = " + this.mcgpIdSF);

                //        fb.setMcgpIdSF(this.mcgpIdSF);

                //        fb.setList();

                    }