1 Reply Latest reply on Apr 22, 2009 12:33 AM by gonorrhea

    DataModel: How to refresh 2 datamodels on the same action

    mpssantos.mpssantos.gmail.com

      Hello there!


      Im having trouble refreshing a datamodel. I have an action, that have two datamodels as flow:


      @Scope(ScopeType.SESSION)
      @Name("manageUsers")
      public class ManageUsersAction implements ManageUsers {
         ...
          
          @DataModel(value="usersToManageList", scope=ScopeType.PAGE)
          private List<UserBean> usersToManageList;
          
          //Roles
          @DataModel(value="rolesWrapperList", scope=ScopeType.PAGE)
          private List<RoleWrapperBean> rolesWrapperList;
           
          @DataModelSelection(value="usersToManageList")
          @Out(required=false, scope=ScopeType.PAGE)
          @In(create=true)
          private UserBean userBean;
          
          @DataModelSelection(value="rolesWrapperList")
          @Out(required=false)
          private RoleWrapperBean selectedRole;
          
          @Factory(value="usersToManageList")
          public void getUsersList() {
               .....
          }
      
          @Factory(value="rolesWrapperList")
          public void findRolesList() {
               ....
          }
      



      I want that the usersToManageList and rolesWrapperList be refreshed each time the page is refreshed or reloaded. if i mark the just one of the DataModel with the PAGE scope, it works fine. When the page is loaded for the first time, both of the factory methods (getUsersList, findRolesList) are called. but if i mark the 2 of them with the PAGE scope, both are called when the page is loaded for the firt time, but when is refreshed just the rolesWrapperList is called. (I can see it with the debugger). I want both to be called.


      Does any one knows why? Does any one know how to create a method on a action that is called on the begin on the instantiation (every time the page is loaed/reloaded)?


      Thaks a lot

        • 1. Re: DataModel: How to refresh 2 datamodels on the same action
          gonorrhea

          1) @DataModelSelection injects; don't use @In for a context variable annotated with @DataModelSelection (also don't use @Out with @DataModel).


          2) A manager component is any component with an @Unwrap method. This method returns the value
          that will be visable to clients, and is called every time a context variable is referenced.


          3) You could possibly use scope=ScopeType.EVENT scope (which is shorter duration than PAGE, it's effectively REQUEST scope), but not sure if that is allowed or not with @DataModel or @Out