4 Replies Latest reply on Nov 24, 2008 10:05 AM by swathi samala

    Example Of Selecting Rows In A Table

    Lee Theobald Newbie

      Hi all,


      I was wondering if someone could point me in the direction of a good example of selecting multiple items in a table using checkboxes.  The kind of thing that you see one applications like GMail (example screenshot).  You select a number of checkboxes in your table and then press an action like delete, move etc. to perform that action on those items.


      I've been looking around but haven't found a good example yet.  I'm just curious of the kind of backing bean structure people use for this kind of thing.


      Thanks for any info.
      Lee,

        • 1. Re: Example Of Selecting Rows In A Table
          Stuart Douglas Master

          Create a class to use for the row, give it a boolean field for the checkbox to bind to.


          Now you need to create a list of these and expose them to the front end.


          There are two ways, expose it through a factory method, @Unwrap or just have it as a List property a seam component. Don't just have the list as a property though, it will work but the performance is lousy because the seam interceptors will get called too many times.


          Now in you dataTable put in a column with a h:selectBooleanCheckbox and bind it to the boolean property on your row.



          Stuart

          • 2. Re: Example Of Selecting Rows In A Table
            swathi samala Newbie

            Actually I am also looking for the same example.. can I get any example of such... as we can do it in Gmail
            thanks
            Swathi

            • 3. Re: Example Of Selecting Rows In A Table
              Bernard Labno Master

              Check out seam dvd example dvdstore/src/com/jboss/dvd/seam/ShoppingCartBean.java and dvdstore/view/checkout.xhtml

              • 4. Re: Example Of Selecting Rows In A Table
                swathi samala Newbie

                Thank You Bernard for the reply but I want to delete the selected item from data table where am using h:selectManyCheckBox when I select few rows and click on delete the selected items should get deleted.
                I just called removed method from action class to delete the selected rows, but am not able to delete


                xhtml


                 <rich:dataTable id="processNodesList" var="nodes" value="#{processNodesList.resultList}" 
                                   rendered="#{not empty processNodesList.resultList}" rowClasses="#{tableLnF.getRowSettings(skinBean.skin)}" 
                                               headerClass="#{tableLnF.getHeaderSettings(skinBean.skin)}"
                                   cellpadding="0" cellspacing="0" columns="3" columnClasses="formFont2">
                                    
                                <rich:column align="left" colspan="1">
                                    <f:facet name="header"><h:outputText style="text-align:left;" value="Select"></h:outputText></f:facet>
                                    <h:selectManyCheckbox value="#{userGroupHome.processName}">           
                                             <f:selectItem itemValue="#{nodes.name}"/>
                                     </h:selectManyCheckbox>
                                </rich:column>
                
                                <rich:column align="left" colspan="1">
                                    <f:facet name="header">Name</f:facet>
                                    #{nodes.name}
                                </rich:column>
                </rich:dataTable>



                ActionClass


                 @Override
                     @End
                     public String remove()
                     {
                          
                               super.remove();
                              return "removed";
                     }