Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
05. Jun 2008, 20:46 CET | Link

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).

2 Replies:
06. Jun 2008, 08:33 CET | Link

Try conversation, which is the intent for such a thing. Just remember to start your conversation somewhere. ;)

 
Dan Hinojosa Seam :: Groovy :: Swing Developer/Consultant/Instructor Albuquerque, NM
06. Jun 2008, 10:38 CET | Link

If you need the data on that single page only and you are not even changing the data, then you can store the list in page scope.

If I am not mistaken you can do that in the getAllUsers() action handler, because writing to page scope in an action handler writes to the new page.

However I would probably rather add a page action for pageB that calls a method that retrieves the values. That way the data will always be present no matter how you navigate to the page (plus the page could be bookmarked).