2 Replies Latest reply on May 9, 2007 2:31 PM by paulharrington

    @DataModelSelection always outjects first value in list

    paulharrington

      I have a class which acts as a backing bean for a page with a datatable. A second class acts as a backing bean for a form, which alows a selected value from the table to be edited.

      In the first class I use the @Datamodel component to outject the list, and the @DataModelSelection to outject the selected item.

      The second class uses the @In annotation to pick up the selected value.

      The problem is that Regardless of which value I click on my list in the xhtml page, the first entry in the list is always outjected, and hence picked up by the second component.

      I am using seam 1.2.1

      Can anyone help?

      thanks

      Paul
      (below is the code for how I use the @DataModel, and @DataModelSelection annotations:

      -----------------------------------------------

      @SerializedConcurrentAccess @Synchronized @Name("appUserListAction")
      @Stateful
      public class AppUserListActionImpl
      {
      ....
      @DataModelSelection
      @Out(required = false)
      private AppUser appUser;

      @DataModel(scope = ScopeType.PAGE)
      private List myCurrentPage;

      @Factory("myCurrentPage")
      @Begin
      public void initCurrentPage()
      {
      myCurrentPage = getService().getCurrentPage();
      }
      }



      @Name("appUserAction")
      @Scope(ScopeType.CONVERSATION)
      public class AppUserActionImpl {
      ....
      @In(required = false, create = true)
      private AppUser appUser;
      ....
      }

        • 1. Re: @DataModelSelection always outjects first value in list
          delphi'sghost

          Can you post your h:datatable or whatever you are using to display the list.

          Off the top of my head, when I get these problems it's because I am using the member variable for the list source as opposed to the context variable. Check that you are using :

           <h:dataTable value="#{myCurrentPage}" var="myvar">
          


          and not :

           <h:dataTable value="#{appUserListAction.myCurrentPage}" var="myvar">
          


          Also, I forget how this works with the Page scope, but it may be that the list is being recreated before being outjected, thus the selection is at the first item since it has just been created.

          Just for fun, try removing the scope on the datamodel just to see if keeping the list around longer works.

          • 2. Re: @DataModelSelection always outjects first value in list
            paulharrington

            Hi DG,

            Thanks for your advice.

            I've realised what the problem is. I was using a tomahawk datatable instead of the standard h:dataTable. When I tested with the standard table the @DataModelSelection works OK.

            By the way do you know if this a bug with tomahawk?

            thanks

            Paul