2 Replies Latest reply on May 5, 2008 12:31 PM by mbinna

    Getting the selection from a ScrollableDataTable

    mbinna Newbie

      Is it possible to outject the selection from a RichFaces' ScrollableDataTable as an object in the context? I don't want to deal with a row number or such things. I want to select a row in the Table and when that row is selected a component in the context should be updated.


      I already tried the following in my session bean:



      @DataModel
      private List<Item> itemList
      @DataModelSelection
      private Item selectedItem



      But when I print out some of the properties of selectedItem, the same values are printed out, no matter which item is selected.

        • 1. Re: Getting the selection from a ScrollableDataTable
          Andy Gibson Novice

          If you change it from the scrollableDataTable to a regular data table, does the selection work?  If not, can you post the relevant pieces of code?


          Cheers,


          Andy Gibson

          • 2. Re: Getting the selection from a ScrollableDataTable
            mbinna Newbie

            Ok, finally I got it working using a h:dataTable and using the annotation DataModel and DataModelSelection. I think the problem was that the action was not triggered in the column but by a button global to all columns of the table.


            I'm relatively new to J2EE and Seam, so it might be possible to get that working too if one as enough experience. If someone has good advice, please let me know. ;-)


            Code from Manager.java:


            @DataModel
            private List<Item> itemList;
                
            @DataModelSelection("itemList")
            private Entity selectedItem;



            Code from list.xhtml:


            <h:dataTable value="#{itemList}" var="item">
              <h:column>
                <h:commandLink value="#{item.description}" action="#{manager.edit}"/>
              </h:column>
            </h:dataTable>



            Regards,
            Manuel Binna