2 Replies Latest reply on Jun 6, 2008 10:38 AM by Stephen Friedrich

    Which scope type should I use ?

    Soon Ee Chua Newbie

      Hi all, I'm a beginner to Seam. Let say I have Page A and Page B in my application.

      In Page A, I have a JSF commandLink below:

      <h:commandLink  action="#{usersV2Action.getAllUsers}" />

      and my session bean as below:


      @Stateless
      @Name("usersV2Action")
      public class UsersV2Action implements IUsersV2 {
          @In(required=false) @Out(required=false, scope=ScopeType.EVENT)
          private List<UserBeanV2> allUsersList;
          public String getAllUsers() {
              allUsersList = new ArrayList<UserBeanV2>();
              UserBeanV2 ubv2 = new UserBeanV2();
              ubv2.setName("User 1");
              allUsersList.add(ubv2);
              return "/pageB";
          }
          public void getAllUsersByAjax() {
              allUsersList = new ArrayList<UserBeanV2>();
              UserBeanV2 ubv2 = new UserBeanV2();
              ubv2.setName("User 2");
              allUsersList.add(ubv2);
          }
      }
      



      and Page B codes below:


      <t:dataTable id="userDataTable" value="#{allUsersList}" var="user">
          <t:column>
           <t:outputText value="#{user.name}" />
          </t:column>                    
      </t:dataTable>
      <a4j:commandLink action="#{usersV2Action.getAllUsersByAjax}" reRender="userDataTable"><t:outputText value="Refresh" /></a4j:commandLink>
      



      In this case, I am using ajax4jsf to refresh the users list.


      Which scope type should I use for allUsersList in order to retain the value in the rest of Page B only and not to use Session scope? In addition, I would want the value of allUsersList to be retained in case I press F5 (refresh button).