1 Reply Latest reply on May 15, 2013 2:42 PM by raphael_lacerda

    RichFaces 4.3.1 datatable rowclick set to ManagedBean

    raphael_lacerda

      Hi guys, i think that my problem is very similar to this one (https://community.jboss.org/message/628257)

      and this one(https://community.jboss.org/thread/164648?start=15&tstart=0)

       

       

      Except for the fact that's a little bit different. They can't even get the selected row from a datatable. I can do this, what i can't do is to get the correct element when i use the rich:dataScroller

       

      I'm using RichFaces 4.3.1, and i can set to the ManagedBean the selected row using rowclick event like this

       

       

      <h:form>
        <rich:dataTable value="#{test.names}" var="n" rows="4">
               <a4j:ajax event="rowclick" listener="#{test.setSelectedItem(n)}" render="@form" />                                        
             <rich:column>
                  <f:facet name="header">Names</f:facet>
                  <h:outputText value="#{n}" />
              </rich:column>
      
              <f:facet name="footer">
                <rich:dataScroller />
              </f:facet>
      
        </rich:dataTable>
          <h:outputText value="#{test.selectedItem}" />
      </h:form>
      

       

      This works just fine! However, when i click to go to the next page on the dataScroller and i click at a specific row , it gets the elements from the first page

      For example:

       

      Page 1 - Names1,Names2,Names3, Names4

      Page 2 - Names4,Names5,Names6, Names8

       

      First step:

          - Click at the " Names 2"

         - The String "Names 2" is displayed

       

      Second step:

          - Navigate to page 2

       

      Third Step

          - Click at the "Names 4"

          - The String "Names 1" is displayed

       

       

       

      The workaround that i've found was to use the propertyActionListener

      <h:commandLink value="Select" >
      
      
         <f:ajax render="@form"/>
         <f:setPropertyActionListener target="#{test.selectedItem}" value="#{n}"></f:setPropertyActionListener>
       </h:commandLink>
      
      
      
      
      

       

      Nevertheless, this is not a very good option for me, because i've gotta make the row clickable, and not to use a link

       

       

       

      is this a bug? what am i doing wrong?

       

      Any Idea?

       

      I've tried with the ManagedBean in different scopes, and none of them worked out