3 Replies Latest reply on Nov 18, 2013 8:42 PM by bleathem

    binding causes the page to reload

    saini.sushant

      I am currently migrating from JSF 1.2/Richfaces 3.3.3. to JSF 2/Richfaces 4.3.2.  I have noticed that on all of my pages if i have a single binding it cuases my page to reload on every ajax call. As soon as i remove the binding, reloading stops. I cannot get rid of all the bindings as there are too many of them. Is there any other way to fix this problem?

        • 1. Re: binding causes the page to reload
          bleathem

          Can you provide an Short, Self Contained, Correct (Compilable), Example reproducing your observations?

          • 2. Re: binding causes the page to reload
            saini.sushant

            Hi Brian,

            I have created a simple example below to show the issue but the fact is that I am currently migrating an 3.3.3 applications to 4.3.2 and my applications has more then hundred pages and we have seen this issue across all the pages. The moment we remove all the bindings from the page, reloading stops and moment we add even 1 binding back, it causes the reloading. 3 developers on my team has confirmed the same.

             

            Please please help me!!! I need to finish upgrading really soon and our application relies on binding extensively.

             

            I have create the simplest example to show this issue. Try putting a break point in init() method and click on the numbers in datatable, you will see init being called again. Then remove the binding and try again, you will see init will not be invoked when you click on numbers. The bean is in view scope.

             

            Here is my test.xhtml

             

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:tr="http://myfaces.apache.org/trinidad">
            
            
                 <h:head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                        <title>Rexus</title>
                        <link rel="stylesheet" type="text/css" href="css/star-skin2.css" />
                        </h:head>
            
              <h:body>
              <h:form>
              <rich:dataTable value="#{testBean.employeeList}" var="arr" binding="#{testBean.datatable}"
              id="searchResultsTable"
                 render="lowerScroller,upperScroller" >
               
              <rich:column sortBy="#{arr.address}"   sortOrder="#{testBean.locationsrtOdr}"  >
                        <f:facet name="header">
                        <a4j:commandLink value="Loc Code" render="searchResultsTable,bldtooltip,bldlocQuickPeek" action="#{testBean.locationSort}" style="xls-font-bold:true" />
                        </f:facet>
                        <a4j:commandLink value="#{arr.address}"  action="#{testBean.onLocationClick()}" />
                        </rich:column>  
            
            
              </rich:dataTable>
            
            </h:form>
            </h:body>
            </html>
            

            Here is the  my TestBean.java

             

            package gov.gsa.pbs.rexus.community.view.bean;
            
            import gov.gsa.pbs.rexus.common.dto.AddressDTO;
            
            import java.util.ArrayList;
            import java.util.List;
            
            import javax.annotation.PostConstruct;
            
            import org.richfaces.component.SortOrder;
            import org.richfaces.component.UIDataTable;
            
            public class TestBean {
            
              private SortOrder locationsrtOdr = SortOrder.unsorted;
              public SortOrder getLocationsrtOdr() {
              return locationsrtOdr;
              }
            
            
              public void setLocationsrtOdr(SortOrder locationsrtOdr) {
              this.locationsrtOdr = locationsrtOdr;
              }
            
            
              private List<AddressDTO> employeeList;
              UIDataTable  datatable;
            
            
              public UIDataTable getDatatable() {
              return datatable;
              }
            
            
              public void setDatatable(UIDataTable datatable) {
              this.datatable = datatable;
              }
            
            
              public List<AddressDTO> getEmployeeList() {
              return employeeList;
              }
            
            
              public void setEmployeeList(List<AddressDTO> employeeList) {
              this.employeeList = employeeList;
              }
            
              @PostConstruct
              public void init() {
            
              employeeList = new ArrayList<AddressDTO>();
            
              for(int i=0;i<10;i++)
              {
              AddressDTO addressDTO = new AddressDTO();
              addressDTO.setAddress("" + i);
              employeeList.add(addressDTO);
              }
            
              }
            
              public void locationSort() {
            
              if (locationsrtOdr.equals(SortOrder.ascending)) {
              setLocationsrtOdr(SortOrder.descending);
                    } else {
                    setLocationsrtOdr(SortOrder.ascending);
                    }
              }
            
              public String onLocationClick()
              {
              System.out.println("sssss");
              return null;
              }
            }
            

            Let me know if you need anything else.

            • 3. Re: binding causes the page to reload
              bleathem

              Is this problem unique to using the view scope?  If you change to Session scope, does the binding work as expected? (just as a check).

               

              Sounds like you might be hitting https://java.net/jira/browse/JAVASERVERFACES-1492, for which the accepted workaround is to set javax.faces.PARTIAL_STATE_SAVING to false.