2 Replies Latest reply on Jun 21, 2007 4:38 AM by paulo5

    Datatable onRowClick firing server side sction controller -

    paulo5

      Hi,

      Has anyone had any success at firing a server side action controller method from an onRowClick event in a datatable?

      The idea is that once a user clicks on a row they are taken to a detail page where they can edit the object that the row represents.

      I can do this by forcing the user to click on a commandButton or commandLink...but I'd rather let them just click on a row (the business demands it).

      My only workaround at the moment is quite messy in that it has a hidden submit button on every row - and when the user clicks on the row, a javascript function causes the button to submit (the action / actionlistener attribute dictates the server side method to call)

      I'm trying to put together a presentation to justify and teach the benefits of richFaces and unfortunately this solution is too messy to include...

      Does anyone have any better solutions?

      Thanks in advance for any help :-)

      Cheers,

      Paul

        • 1. Re: Datatable onRowClick firing server side sction controlle
          baz

          Please search the forum and you will find a solution that at least works for us.
          http://jboss.com/index.html?module=bb&op=viewtopic&t=106284
          and
          http://jboss.com/index.html?module=bb&op=viewtopic&t=107198

          • 2. Re: Datatable onRowClick firing server side sction controlle
            paulo5

            Thanks for your response - I did do some searches but did was obviously searchng for the wrong words :-)

            Either way I took a little bit from several of the responses and managed to fire my action controller:

            My Data Table

            <rich:dataTable
             id="widgetTable"
             styleClass="resultsTable"
             value="#{widgetSummaryManager.widgetDataModel}"
             var="widgetRecord"
             onRowMouseOver="switchElmtClass(this, 'highlightRow', 'normalRow')"
             onRowMouseOut="switchElmtClass(this, 'highlightRow', 'normalRow')"
             summary="Provides a list of widgets available"
             headerClass="tableHeader"
             columnClasses="idField">
             <a4j:support event="onRowClick" action="#{widgetSummaryManager.selectWidget}"
             actionListener="#{widgetSummaryManager.viewWidget}"/>
            
            ....


            My widgetSummaryManager.selectWidget Action controller

            public String selectWidget() {
             logger.info("trying to get small widget dto");
             SmallWidgetDTO smallWidgetDTO = (SmallWidgetDTO) widgetDataModel.getRowData();
             logger.info("Attempting to get widget using id of "+ smallWidgetDTO.getId());
             WidgetDTO widgetDTO = getSearchMgr().getWidget(smallWidgetDTO.getId());
             setSelectedWidget(widgetDTO);
             return "widgetDetail";
            }
            


            and the navigation rule in faces-config.xml that directs me to the next page...

            <navigation-rule>
             <from-view-id>/pages/widgetSummary.jsp</from-view-id>
             <navigation-case>
             <from-outcome>widgetDetail</from-outcome>
             <to-view-id>/pages/widgetDetail.jsp</to-view-id>
             </navigation-case>
            navigation-rule>
            


            Thanks again for your help pointing me in the right direction and apologies for not managing to find it myself :-)

            Cheers