7 Replies Latest reply on Feb 11, 2011 8:53 PM by anonyin

    rich:dataTable onRowDblClick

    anonyin

      Need help in implementing the following scenario.

       

       

      <rich:dataTable rows="10" value="#{bean.resultList}" var="_result" width="100%" style="width:100%;"

                                      onRowDblClick="openDetail('#{_result.Id}');" >

       

      I have a Search and Results screen and on double click of a column I want to open the details in a ModalPanel. As shown above the dataTable is pointing to a "searchResultList" in the bean. On double click of the row I want to retreive the object of the selected row and process the data in it.

       

       

      How do I acheive(access the selected object) this without iterating the complete list(checking for the id passed) ? (I can do by storing the complete list in a map by Id, but I'm looking for a better approach than this please).

       

       

      I have a checkbox in each row of the dataTable, how can I access the selected row Ids in the bean when the bean method is invoked on click of  button ?

       

      Please note search is on an external service and is not from database and my bean is a POJO in Session scope.

       

      Thanks In Advance.

      Kiran

        • 1. rich:dataTable onRowDblClick
          ilya40umov

          1) Try this approach:

           

          <rich:dataTable rows="10" value="#{bean.resultList}" var="_result" width="100%" style="width:100%;">

           

                    <a4j:support event="onRowDblClick" action="#{bean.selectRow}"  reRender="panelContent" > \

            <a4j:actionparam name="id" value="#{_result.id}" assignTo="#{bean.selectedId}"/>

          </a4j:support>

           

          • Then in #{bean.selectRow} I suggest you to find this object again by ID from DB. It looks like the best solution for me because this object can be changed by another user and thus you will show the most recent data in your panel.
          • Another solution is binding rich:dataTable to UIData in your bean. Then you will be able to use
            java.lang.ObjectgetRowData()
                      Return the data object representing the data for the currently selected row index, if any.

           

          2) Look at the following link:

          http://stackoverflow.com/questions/2524514/how-to-use-jsfs-hselectbooleancheckbox-with-hdatatable-to-create-one-object-pe

          Then I you can add a4j:support to h:selectManyCheckbox and also add selectAll checkbox to header(I guess that the best way to do that is implementing selectAll/diselectAll on the server side and then reRender the table)

          • 2. rich:dataTable onRowDblClick
            anonyin

            Thanks A Lot IIlya,

             

            Will try out these options.

             

            Kiran.

            • 3. rich:dataTable onRowDblClick
              anonyin

              IIlya,

               

              Both the solutions suggested above by you worked for me. But I have another scenario here.

               

              I have the pagination implemented using the <rich:datascroller ..> for the datagrid. I want the checkboxes selected across different pages to be intact(while moving between different pages) and the values to be available when I submit the page to my bean method. Currently the Map<String,boolean> is refelecting only the 10(rows) values in the current page I'm in.

               

              Is there anyway to acheive the checkbox selection across different pages posted to the bean method when submitted ? Let me know if you want me to start a new discussion for this.

               

              Thanks In advance.

               

              Kiran.

              • 4. rich:dataTable onRowDblClick
                ilya40umov

                As I understood a4j:keepAlive tag should do the trick in your case.

                • 5. rich:dataTable onRowDblClick
                  anonyin

                  Ilya I tried "a4j:keepAlive" but it doesn't help.

                   

                  Let me try to explain my scenario one more time.

                   

                  <rich:dataTable...> with <rich:dataScroller...> pagination. First column in the dataTable is checkbox. Say I have 2 pages of data. If I check 2 checkboxes(rows) in the First page and then I navigate to 2nd page using the pagination button provided by <rich:dataScroller....> and come back to the First page. The 2 checkboxs I have checked before are no longer checked now.

                   

                  As shown below, my Seam POJO is in SESSION scope and the datatable is pointed to a List in that pojo.

                   

                  @Scope(ScopeType.SESSION)

                  @Name("sectorBean")

                  public class SectorBean

                  {

                  ..........

                   

                  private List resultList;

                  ..........

                  }

                  <rich:dataTable rows="10" value="#{sectorBean.resultList}" .......>

                   

                  How can I acheive the checkboxes selected information intact while I'm navigating across different pages.

                   

                  Thanks

                  Kiran.

                  • 6. rich:dataTable onRowDblClick
                    anonyin

                    In otherwords I am looking for a solution for below scenario

                     

                    http://community.jboss.org/message/35908

                     

                    Thanks

                    Kiran.

                    • 7. rich:dataTable onRowDblClick
                      anonyin

                      Nevermind,

                       

                      I got the answer from one of your previous posts. You are awesome.

                       

                      http://community.jboss.org/message/17631#17631

                       

                      Thanks

                      Kiran.