-
1. Re: Why PAGE context variable = NULL
damnh Dec 18, 2007 8:21 PM (in response to damnh)what is this problem? Please help me
-
2. Re: Why PAGE context variable = NULL
pmuir Dec 20, 2007 8:17 AM (in response to damnh)Post, clearly, the execution flow of your app involving these variables/components.
-
3. Re: Why PAGE context variable = NULL
damnh Dec 20, 2007 9:24 PM (in response to damnh)I want to pass variable mode (or variable with type Object) from /list.xhtml page to /register.xhtml page, I used PAGE scope to pass.
@Stateful @Name("listAction") @Scope(SESSION) @Restrict("#{identity.loggedIn}") public class ListAction implements IListAction { ......... @In(required = false) @Out(required = false, scope = ScopeType.PAGE) private String mode; public void search() { mode = "searched"; //get list to display list.xhtml .................. } .......... }
@Stateful @Name("regAction") @Restrict("#{identity.loggedIn}") public class RegAction implements IRegAction { ........... @In(required = false) @Out(required = false, scope = ScopeType.PAGE) private String mode; public void init() { if ("searched".equals(mode)) { .... } else { .... } } }
pages.xml<page view-id="/list.xhtml" login-required="true"> <navigation from-action="#{listAction.search}"> <redirect view-id="/list.xhtml" /> </navigation> <navigation from-action="#{regAction.init}"> <begin-conversation flush-mode="manual" /> <redirect view-id="/register.xhtml" /> </navigation> </page>
-
4. Re: Why PAGE context variable = NULL
pmuir Dec 21, 2007 12:38 PM (in response to damnh)Those are two different pages, so you won't have the same page context for both pages... (i.e. what you are trying to do is flawed from a design perspective)
-
5. Re: Why PAGE context variable = NULL
nguyenhaugiang Dec 23, 2007 9:05 PM (in response to damnh)Pete,
I have exactly same problem.
In the case action A render page a, from page a call an method of action B:
A -> a -> B
A and B share the same page scope
next we do the same thing:
B -> b -> C
B and C share the same page scope
So, if we declare page scope field with @in @out in A, B, C,
we can pass data from A -> B -> C by using page scope
is that right?
The problem is that in flow A -> a -> B -> b -> C,
page context is destroy if after invoking B,
page flow is redirected to page b.
(Page context still "alive" if render)
The difference is render(OK) and redirect(fail).
Any help would be appreciated.
Thanks,
Giang -
6. Re: Why PAGE context variable = NULL
pmuir Dec 24, 2007 4:52 AM (in response to damnh)Yes, this is to be expected. After calling B you do a redirect to another page, hence the page context changes. (B is called in the context of A). Doing a redirect is essentially a call to a new page. You should use the conversation scope for passing a variable through a sequence of logically connected pages.
-
7. Re: Why PAGE context variable = NULL
nguyenhaugiang Dec 24, 2007 5:29 AM (in response to damnh)Thank you for your reply.
As in http://www.jboss.com/index.html?module=bb&op=viewtopic&t=124426,
we want to maintain state through a sequence of pages, but do not share SMPC.
Page Context var can solve our case? -
8. Re: Why PAGE context variable = NULL
pmuir Dec 24, 2007 7:22 AM (in response to damnh)No, the page context only lasts as long as a page. You could use a conversation and a standard PC injected with @PersistenceContext to get a new PC for each request. This is really an anti-pattern with Seam though, and you would be better understanding lazy loading properly.