8 Replies Latest reply on Mar 29, 2011 3:06 AM by ilya_shaikovsky

    Richfaces 4 + datatable + onrowclick

    aagenielsen

      We are migrating a small jsf application from 3.3.2 to 4.x. When using version 3 have been using the a4j:support tag for handling click in datatables, like this

       

      <rich:extendedDataTable rowKeyVar="rkv" frozenColCount="1" id="userTable"

                                              rows="#{findUserBean.rowCount}" value="#{findUserBean.baUserInfoList}" var="user" sortMode="single" sortOrder="#{findUserBean.order}" selection="#{findUserBean.selection}"

        style="cursor: pointer;" selectionMode="single">

                                              <a4j:support event="onRowClick" action="#{findUserBean.takeSelection}" oncomplete="Richfaces.hideModalPanel('progress');" onsubmit="Richfaces.showModalPanel('progress');" />

       

      Does anybody have some recommendations on how to do it in version 4 ?

       

      /aage

        • 1. Richfaces 4 + datatable + onrowclick
          nbelaevski

          Hi Aage,

           

          Use a4j:ajax for 'rowclick' event.

          • 2. Richfaces 4 + datatable + onrowclick
            aagenielsen

            Point taken ;-)

             

            But it is the action part that we miss.

             

            /aage

            • 3. Richfaces 4 + datatable + onrowclick
              nbelaevski

              Action is not available, use 'listener' attribute.

              • 4. Re: Richfaces 4 + datatable + onrowclick
                aagenielsen

                But is actionlisteners not used for logic + non navigtion handling and actions for logic + navigation handling ?

                 

                And how to use the navigation handler in an actionslistener - more specific how to get the context for the handleNavigation method -  is it the FacesContext.getCurrentInstance() ?

                 

                /aage

                • 5. Re: Richfaces 4 + datatable + onrowclick
                  ilya_shaikovsky

                  then use jsFunction instead. It's provides action/actionListener attributes and being and action component. a4j:ajax is just a behavior and designed according to standard JSF principles(parent component events like action/actionListener fired by parent button/link component, valueChange by inputs and so on). And the behavior itself provides only the listener for behavior event.

                   

                  P.S. in case of using the jsFunction - you should pass parameter to identify the row additionally.

                  • 6. Re: Richfaces 4 + datatable + onrowclick
                    aagenielsen

                    Hmm we have tried without any luck. You mean something like:

                     

                    <rich:extendedDataTable id="userdatatable" name="userdatatable"

                                                                      value="#{userBean.baUserInfoList}" var="user" rows="10" onrowclick="showUser();">

                    <a4j:jsFunction name="showUser" action="showusernavigationrule"><a4j:param name="suser" assignTo="#{userBean.selection }"></a4j:param> </a4j:jsFunction>

                    ...

                    ...

                     

                     

                    /aage

                    • 7. Richfaces 4 + datatable + onrowclick
                      sadinenianil

                      Here is the code that works -

                       

                      <rich:extendedDataTable id="userdatatable" name="userdatatable"

                                                                        value="#{userBean.baUserInfoList}" var="user" rows="10" onrowclick="showUser('#{user.id}');">

                            <a4j:jsFunction name="showUser" action="showusernavigationrule"><a4j:param name="param1" assignTo="#{userBean.selectedRowId }"></a4j:param> </a4j:jsFunction>

                       

                      I am not sure if this resolves your issue. Here the problem is, you can assign only id of row selected, Not the complete selected row object.

                       

                      Thanks,

                      Anil.

                      • 8. Richfaces 4 + datatable + onrowclick
                        ilya_shaikovsky

                        to assign complete object you should just use f:setPropertyActionListener or to define converter for object if using a4j:param.