11 Replies Latest reply on Apr 8, 2010 10:31 AM by kjo2x

    setPropertyActionListener not being invoked after 2nd page ...

      Hi,

       

      I've tried this with richfaces 3.3.2 and 3.3.3 version running on jboss4.2.2GA -- I have a dataTable with a commandLink attached to one of the columns.  When the user clicks on one of the links, I want to get the row object.  So I used the setPropertyActionListener to capture the selected object.  I then use this selected object to display data in a modal panel.  When I render the page, it works fine for the first page in the dataTable.  When I click on the dataScroller to move to the next page, when I click on one of the links from the row, it doesn't give me the current selected row/object.  Since my backing bean is stored in the session, it is displaying what I selected last.  If I go back to the first page, it works fine.  I put a trace in the set method in my backing bean and noticed that it is only called on the first page, but any subsequent pages, it doesn't get called.  Here is how my .xhtml file looks like:

       

      <body>
        <f:view>
           <a4j:outputPanel>
           <h:form>
           <rich:dataTable id="data"
               styleClass="scrollerTable"
               headerClass="standardTable_Header"
               footerClass="standardTable_Header"
               rowClasses="standardTable_Row1,standardTable_Row2"
               var="car"
               value="#{scrollerList.list}"
               preserveDataModel="false"
               rows="10">
            <h:column>
              <h:outputText value="#{car.id}" />
            </h:column>
            <h:column>
              <h:outputText value="#{car.type}" />
            </h:column>
           <h:column>
              <h:outputText value="#{car.color}" />
            </h:column>
            <h:column>
               <a4j:commandLink reRender="data" value="Hello">
                  <f:setPropertyActionListener value="#{car}" target="#{scrollerList.selectedCar}"/>
               </a4j:commandLink>
            </h:column>
            <f:facet name="footer">
               <rich:datascroller id="paginator"
                  ajaxSingle="false"
                  for="data"
                  maxPages="10"
                  page="#{scrollerList.pageNumber}"></rich:datascroller>
            </f:facet>
           </rich:dataTable>       
           </h:form>
           </a4j:outputPanel>
      </f:view>
        </body>
      </html>

       

      My backing bean has these methods:

       

      public SimpleCar getSelectedCar() {
        return mSelectedCar;
      }

      public void setSelectedCar(SimpleCar pSelectedCar) {
        System.out.println("Selected car is : " + pSelectedCar.getId());
        this.mSelectedCar = pSelectedCar;
      }

       

      I saw this thread http://community.jboss.org/message/50601#50601 but the solution to have a member instead of a method to set the selected row doesn't work.  I get an error when it tries to call the setter method in my bean.

       

      Any suggest is greatly appreciated.

       

      Thanks

        • 1. Re: setPropertyActionListener not being invoked after 2nd page ...

          I've specified an action to the commandLink and it too seems to be only called on the first page. Any subsequent pages, nothing happens when I click on the link.

           

          <a4j:commandLink actionListener="#{scrollerList.actionListener}" value="Hello" action="#{scrollerList.linkAction}" immediate="true"/>

           

          The method in my bean:

           

          public void actionListener(ActionEvent pEvent)
          {
          System.out.println("** Inside the listener**");
          }

          • 2. Re: setPropertyActionListener not being invoked after 2nd page ...
            nbelaevski

            Hi Joel,

             

            The page code you've posted works perfectly for me. Can you please:

             

            - add rich:messages and check if there any

            - post bean code

             

            ?

            • 3. Re: setPropertyActionListener not being invoked after 2nd page ...

              Hi Nick,

               

              I've added the rich:messages in the page and only thing I see with ERROR is "07:41:32,707 ERROR [STDERR] Apr 5, 2010 7:41:32 AM com.sun.facelets.compiler.Tag LibraryConfig loadImplicit".  I googled this message and it seems that it can be ignored.

               

              This is the bean I've used with the page:

               

              public class DataScrollerList implements Serializable {

              /**
              *
              */
              private static final long serialVersionUID = -8879155749797180215L;
              private Long rowCount = new Long(10);
              private int mPageNumber=1;
              private SimpleCar mSelectedCar;
              private HtmlDataTable mCarTable;

              /**
              * @return the mSelectedCar
              */
              public SimpleCar getSelectedCar() {
              return mSelectedCar;
              }

              /**
              * @param mSelectedCar the mSelectedCar to set
              */
              public void setSelectedCar(SimpleCar pSelectedCar) {
              System.out.println("Selected car is : " + pSelectedCar.getId());
              this.mSelectedCar = pSelectedCar;
              }

              public Long getRowCount()
              {
              return rowCount;
              }

              public void setRowCount(Long rowCount)
              {
              this.rowCount = rowCount;
              }

              private List carList = new ArrayList();

              public DataScrollerList()
              {
              for (int i = 1; i < 995; i++)
              {
                carList.add(new SimpleCar(i, "Car Type " + i, "blue")); 
              }
              }

              public List getList()
              {
              return carList;
              }

              public int getPageNumber()
              {
              return mPageNumber;
              }

              public void setPageNumber(int pPageNumber)
              {
              mPageNumber = pPageNumber;
              }

              public void setCarTable(HtmlDataTable pTable)
              {
              mCarTable = pTable;
              }

              public HtmlDataTable getCarTable()
              {
              return mCarTable;
              }

              public String linkAction()
              {
              System.out.println("Linked action invoked....");
              return "SUCCESS";
              }

              public void actionListener(ActionEvent pEvent)
              {
              System.out.println("** Inside the listener**");
              }
              }

               

              ** SimpleCar **

               

              public class SimpleCar implements Serializable{
              /**
              *
              */
              private static final long serialVersionUID = 5749054962250308627L;
              private int id;
              private String type;
              private String color;

              public SimpleCar(int id, String type, String color)
              {
              super();
              this.id = id;
              this.type = type;
              this.color = color;
              }

              public String getColor()
              {
              return color;
              }

              public void setColor(String color)
              {
              this.color = color;
              }

              public int getId()
              {
              return id;
              }

              public void setId(int id)
              {
              this.id = id;
              }

              public String getType()
              {
              return type;
              }

              public void setType(String type)
              {
              this.type = type;
              }
              }

              • 4. Re: setPropertyActionListener not being invoked after 2nd page ...
                nbelaevski

                Joel,

                 

                Please try removing session-scoped binding for data table component and try.

                • 5. Re: setPropertyActionListener not being invoked after 2nd page ...

                  Hi Nick,

                   

                  If I change the scope of the bean associated with the table to request, then the dataScroller stops working.  It navigates up to 2nd page and it stops there.  Also, even though I can get to the 2nd page, the commandLink doesn't work, it doesn't track my selected row, only when I go back to the first page.

                  • 6. Re: setPropertyActionListener not being invoked after 2nd page ...
                    nbelaevski

                    Ok, leave session scope for bean, but remove binding.

                    • 7. Re: setPropertyActionListener not being invoked after 2nd page ...

                      Hi Nick,

                       

                      This is how my dataTable call looks like without binding:

                       

                      <rich:dataTable id="data"
                         styleClass="scrollerTable"
                         headerClass="standardTable_Header"
                         footerClass="standardTable_Header"
                         rowClasses="standardTable_Row1,standardTable_Row2"
                         var="car"
                         value="#{scrollerList.list}"
                         rows="10">

                       

                      It still on works on the first page.

                      • 8. Re: setPropertyActionListener not being invoked after 2nd page ...
                        nbelaevski

                        I"ve tried your code - it works ok for me. Please prepare small runnable example that will demonstrate the problem and attach it to this forum thread.

                        • 9. Re: setPropertyActionListener not being invoked after 2nd page ...

                          Hi Nick,

                           

                          I have uploaded earlier this week the simple app that I'm using to test on thread https://community.jboss.org/message/535613#535613.  I've also have the bean source code inside the war file.

                           

                          Thanks

                          • 10. Re: setPropertyActionListener not being invoked after 2nd page ...
                            nbelaevski

                            I've checked .war file. Here is what is causing problems:

                             

                             

                              <context-param>
                                 <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
                                 <param-value>true</param-value>
                              </context-param>
                            
                            
                            • 11. Re: setPropertyActionListener not being invoked after 2nd page ...

                              I've removed that entry in the web.xml and it seems to be working now.

                               

                              Thanks