-
1. Re: Post-redirect and restart conversation with one click
wangliyu Jul 30, 2010 2:10 PM (in response to wangliyu)actually in JSF2 I found a there is trick to perform page action:
<f:metadata> <f:event type="preRenderView" listener="#{bean.loadAction}" /> </f:metadata>
So it should be possible to do Post-redirect trick with CDI and JSF2.
-
2. Re: Post-redirect and restart conversation with one click
wangliyu Jul 30, 2010 2:26 PM (in response to wangliyu)In Weld there is a bean called ConversationManager.
@Inject ConversationManager manager; @Inject Conversation conversation; public string restart() { conversation.end(); manager.cleanupConversation(); conversation.begin(); }
I tried with GF3.0.1, it works.
Can anyone from the Weld team confirm this usage?
Thanks,
Liyu -
3. Re: Post-redirect and restart conversation with one click
andygibson.contact.andygibson.net Aug 2, 2010 10:21 AM (in response to wangliyu)Why not end the conversation and do a faces redirect, and in the new page, if there is no conversation, start one using the loadAction method?
Cheers,
Andy Gibson
-
4. Re: Post-redirect and restart conversation with one click
wangliyu Aug 3, 2010 9:19 AM (in response to wangliyu)I prefer to use post-redirect, but there are several issues with this solution:
1, it requires the whole page refreshing, in my application, there is only one view (we use AJAX refreshing/replacing some parts of the view), not every components on the page has state mapping on the server side (for example the menu's collapse/expand status).
2, In JSF2.0 to redirect the page from the action return, you have to add "?faces-redirect=true" to the result, for example:
return "home?faces-redirect=true";
3, we may need run different page load actions at runtime (depends on the menu user selected). and if user selected the menu before redirection, then I have to have something to store the EL and eval it after redirect. -
5. Re: Post-redirect and restart conversation with one click
pmuir Aug 4, 2010 12:48 PM (in response to wangliyu)
Wang Liyu wrote on Jul 30, 2010 14:26:
In Weld there is a bean called ConversationManager.@Inject ConversationManager manager; @Inject Conversation conversation; public string restart() { conversation.end(); manager.cleanupConversation(); conversation.begin(); }
I tried with GF3.0.1, it works.
Can anyone from the Weld team confirm this usage?Yes, this is the way we intend for you to do this. In Weld 1.1 we will promote this to a user API, and document it.
-
6. Re: Post-redirect and restart conversation with one click
wangliyu Aug 9, 2010 8:07 AM (in response to wangliyu)Thanks for answer this, it has been a issue since I started with Seam (I really like CDI), but the ConversationManager class is not in the CDI APIs, are you going to add this to the Spec?
-
7. Re: Post-redirect and restart conversation with one click
nickarls Aug 9, 2010 10:55 AM (in response to wangliyu)A proposal has been sent to the EG for possible inclusion in the MR. A long time ago.