7 Replies Latest reply on Oct 25, 2007 12:47 PM by j-pro

    scrollableDataTable onRowClick gets data from the second cli

    j-pro

      Good afternoon!

      Have noticed that I can get selected row data only after 2nd and next clicks. I'll explain. I have:

      <h:form id="staffDataTable_Form">
       <rich:scrollableDataTable height="200px" rowKeyVar="rkv" frozenColCount="1"
       binding="#{staffSDTableMan.sdTable}" selection="#{staffSDTableMan.scrollableDataTableSelection}"
       rowClasses="sdt_row1,sdt_row2" selectedClass="sdt_row_selected" activeClass="sdt_row_active"
       width="470px" id="staffDataTable" rows="#{amBean.employeeListMan.listSize}" columnClasses="sdt_col"
       value="#{amBean.employeeListMan.staffEmployees}" var="employee" sortMode="single">
      
       <a4j:support event="onRowClick" onSubmit="this.style.backgroundColor='#000000" actionListener="#{staffSDTableMan.sdtRowSelected}"/>
      
       <rich:column id="firstName">
       <f:facet name="header"><h:outputText styleClass="sdt_head" value="First Name" /></f:facet>
       <h:outputText value="#{employee.firstName}" />
       </rich:column>
      
       <rich:column id="lastName">
       <f:facet name="header"><h:outputText styleClass="sdt_head" value="Last Name" /></f:facet>
       <h:outputText value="#{employee.lastName}" />
       </rich:column>
      
       <rich:column id="sex">
       <f:facet name="header"><h:outputText styleClass="sdt_head" value="Sex" /></f:facet>
       <h:outputText value="#{employee.sex}" />
       </rich:column>
      
       <rich:column id="birthDate">
       <f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Date" /></f:facet>
       <h:outputText value="#{employee.birthDate}" />
       </rich:column>
      
       <rich:column id="birthPlace">
       <f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Place" /></f:facet>
       <h:outputText value="#{employee.birthPlace}" />
       </rich:column>
      
       </rich:scrollableDataTable>
      
       <BR style="text-size:3px;"/>
      
       <a4j:commandButton action="#{staffSDTableMan.prepareNewWorker}" value="Make prikaz"></a4j:commandButton>
       <a href="javascript:Richfaces.showModalPanel('editWorker_panel',{width:700, top:200})">Edit</a>
      
      </h:form>


      And here is my sdtRowSelected method:
      public void sdtRowSelected(ActionEvent event)
       {
       System.out.println("==============>>>>>>>>>>>>>>>>>>>>>> rowSelected");
      
       Iterator keys = this.scrollableDataTableSelection.getKeys();
      
       while(keys.hasNext())
       {
       System.out.println("hasNext!");
       Object key = keys.next();
       }
       System.out.println("Finished!");
       }


      When I redeploy my application, and run it for the first time, my first click gives such log:
      16:26:32,970 INFO [STDOUT] ==============>>>>>>>>>>>>>>>>>>>>>> rowSelected
      16:26:32,970 INFO [STDOUT] Finished!


      and the second, and other next clicks(even after Ctrl+F5) give:
      16:26:48,205 INFO [STDOUT] ==============>>>>>>>>>>>>>>>>>>>>>> rowSelected
      16:26:48,205 INFO [STDOUT] hasNext!
      16:26:48,205 INFO [STDOUT] Finished!


      I wonder why does it happen? Do I do something wrong, or it's some kind of a bug?


      P.S.: I've also tried the way I make it with simple dataTable, like this:
      Integer currIndex = getSdTable().getRowIndex();
      List allData = (List) getSdTable().getValue();
      Object rowData = new Object();
      rowData = allData.get(currIndex);


      but currIndex was always -1. That's why I've decided to make as above, but I'm surprised with that second click...

      Thanks for your answer in advance.

        • 1. Re: scrollableDataTable onRowClick gets data from the second
          ivan.tufegdzic

          Hi,
          try to use for value, list with annotation @DataModel
          and for selected rows also out variable which has @DataModelSelectionIndex

          • 2. Re: scrollableDataTable onRowClick gets data from the second
            j-pro

            Thanks for your answer.

            I don't use Seam. But DataModel annotation is from Seam, as far as I know.

            I hope there is another solution for my environment: JSF 1.2, Facelets, RF 3.1.0, JBoss 4.2.0.GA.

            • 3. Re: scrollableDataTable onRowClick gets data from the second
              j-pro

              By the way, just figured out - the logs always show previous clicked row data. For example if I have:

              row 1: user1 | forum1
              row 2: user2 | forum2

              then if I click on the row 1, my method gives me no data. but if I then click on the row 2 - it gives me data of the row 1. Is it ok?

              • 4. Re: scrollableDataTable onRowClick gets data from the second
                rocky9

                I had exactly the same issue but thought it was some browser glitch. I I switched to alternate means that are working perfectly for me. I am using the following:

                - for updating the java bean values with selected row params I use a4j:actionparam under a4j:support for event="onRowClick"

                - for rerendering some other components using reRender attribute

                - for calling a java bean method using a actionListener for the a4j:support

                ---------------------
                <a4j:support event="onRowClick" reRender="txnDetailsPanelId">
                <a4j:actionparam name="txnInPresentContext" value="#{row.txnGuid}" assignTo="#{txn_grp_details_view_bean.txnInPresentContext}"/>
                </a4j:support>

                ----------------------
                <a4j:support id="a4jSuppForTxnGrpRowClickId"
                event="onRowClick"
                actionListener="#{app_details_view_bean.tgRowSelected}"
                reRender="datPanId,daaPanId,loadPanId"/>
                ----------------------

                • 5. Re: scrollableDataTable onRowClick gets data from the second
                  j-pro

                  Thanks, rocky9. But I can't understand, why should I write additional code with actionparam, if all the actions can be done in actionListener? The problem is that in actionListener always is accessible only previously clicked row...

                  Can someone from developers make some comments on that please?

                  • 6. Re: scrollableDataTable onRowClick gets data from the second
                    j-pro

                    Dear Rich Faces developers! Can anybody tell me if the method I use in action listener above(scrollableDataTableSelection.getKeys()) is wrong for getting currently clicked row data? If it's wrong, then please, give some advices on what is better to use? Because I think that there should be some other ways instead a4j:actionparam. Like for rich:dataTable for example(HtmlDataTable.getValue() and HtmlDataTable.getRowIndex()).

                    I just want to solve the problem...

                    Thank you very much.

                    • 7. Re: scrollableDataTable onRowClick gets data from the second
                      j-pro

                      http://jira.jboss.com/jira/browse/RF-1248 created, because this bug affects latest 3.1.3 snapshots.