-
1. Re: Conversations... Ending and Starting a new conversation in another controller.
luksa Aug 29, 2013 1:27 AM (in response to tony.herstell1)1 of 1 people found this helpfulCalling .end() on a conversation doesn't actually end or destroy it. It only changes the conversation from long-running to transient. The conversation is destroyed at the end of the request (if it is transient at that time). This means that calling .end() and then immediately begin() on a conversation doesn't actually do anything.
So to answer your question: it's not possible to destroy and then create a new conversation in the same request. You'd have to split this among two requests (the first request ends the conversation and then redirects to another view, passing data to it, and the other view then starts a new conversation)
-
2. Re: Conversations... Ending and Starting a new conversation in another controller.
tony.herstell1 Aug 29, 2013 1:57 AM (in response to luksa)Well that's going to be a problem based on the use Case...
Give a finish what I am doing button and then a go back to the list of "stuff" button is not going to wash...
Shame about Hibernate as the correct way was the way I had it... Session for list of stuff and a conversation to do something to it... and then back to the list... using events to update the list of things (if necessary).
-
3. Re: Conversations... Ending and Starting a new conversation in another controller.
wangliyu Sep 3, 2013 7:51 AM (in response to tony.herstell1)1 of 1 people found this helpfulCDI won't work that way, you have to do POST-REDIRECT-GET trick, first end() conversation in POST, and pass the parameters that you want to keep in the redirect, in GET begin() conversation. if you want some beans cross multiple conversations, then make it @SessionScoped.
If you using JSF 2.1+, you have to do some trick (for example begin conversation in Before-RENDER-View-phase listener for GET request)
-
4. Re: Conversations... Ending and Starting a new conversation in another controller.
tony.herstell1 Sep 3, 2013 6:32 PM (in response to wangliyu)Can you elaborate???
>> POST-REDIRECT-GET trick
I am very keen to see an example.
>> if you want some beans cross multiple conversations, then make it @SessionScoped
I have taken great PAIN in changing all my 15 SessionScoped "choose from a list of the XXX entites" beans over to RequestScope (and fixed all the LIEs in the process) for "efficiency" (even though I hammer the DB massively now)... I am not keen in adding in more Sessions Scoped beans if I can help it.
I only need to pass an "Id" between the two conversation beans.
-
5. Re: Conversations... Ending and Starting a new conversation in another controller.
wangliyu Sep 5, 2013 8:58 AM (in response to tony.herstell1)POST(AJAX)-REDIRECT-GET:
in the normal JSF action, call Conversation.end(); and then return value that either configured in the faces-config.xml is redirect to next step or call return "targetPage?id={value}&PRG=true&faces-redirect=true";
create a BeforeRenderPagePhaseListener or page action, check if the PRG=true, Call "Coversation.begin()", also mapping the id to your bean's property.