4 Replies Latest reply on Feb 3, 2009 12:35 PM by dxxvi

    ExtendedDataTable: how to reset the selection programmatical

      I have an extended data table with selectionMode of single. I also have that data table and selection bound to some properties of a bean. When I select a row, it becomes red. I want to click a link to reset that red to normal. How could I do that?

      Thank you.

        • 1. Re: ExtendedDataTable: how to reset the selection programmat
          ilya_shaikovsky

          so just clear the set with your selection in your action.

          • 2. Re: ExtendedDataTable: how to reset the selection programmat

            Is that the clear method of SimpleSelection?

            One more question: the <rich:extendedDataTable> has to be bound to a request-scoped object. Is that also true with selection?

            • 3. Re: ExtendedDataTable: how to reset the selection programmat
              ilya_shaikovsky

              where are you storing your selection? Just clear the collection in action.

              Any components shoud be bound to a request-scoped object (if you talking about binding attribute)

              selection could be bound to session scoped bean without problems.

              • 4. Re: ExtendedDataTable: how to reset the selection programmat

                 

                "ilya_shaikovsky" wrote:
                where are you storing your selection? Just clear the collection in action.

                I still don't understand your instruction because I don't have a collection to store. What I do with selection is:
                <rich:extendedDataTable selection="#{bean.selection}" ...>
                

                And to get rows are selected (maybe that is the collection you're talking about), I have to iterate over the row keys in the selection, feed each row key to the data table to get each row. Could you give an example of clearing the collection?
                "ilya_shaikovsky" wrote:
                selection could be bound to session scoped bean without problems.

                The problem I have when I bind the selection to a session scoped bean is, for example, I display a list of cars, clicking on a car will show the car detail below the car list. Next time I come to this page, that car is already selected but no car is shown in the car detail box.
                So, my question is: is it ok to bind the selection to a request scope bean? Then my faces-config.xml will be:
                <managed-bean>
                 <managed-bean-name>bean</managed-bean-name>
                 <managed-bean-scope>session</managed-bean-scope>
                 <managed-property>
                 <property-name>dataTableInBean</property-name>
                 <value>#{dataTable}</value>
                 </managed-property>
                 <managed-property>
                 <property-name>selectionInBean</property-name>
                 <value>#{selection}</value>
                 </managed-property>
                </managed-bean>
                
                <managed-bean>
                 <managed-bean-name>dataTable</managed-bean-name>
                 <managed-bean-class>org.richfaces.component.html.HtmlExtendedDataTable</managed-bean-class>
                 <managed-bean-scope>request</managed-bean-scope>
                </managed-bean>
                
                <managed-bean>
                 <managed-bean-name>selection</managed-bean-name>
                 <managed-bean-class>org.richfaces.model.selection.SimpleSelection</managed-bean-class>
                 <managed-bean-scope>request</managed-bean-scope>
                </managed-bean>