-
1. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
luksa Nov 6, 2012 8:41 AM (in response to lucaster)1 of 1 people found this helpfulYup, exactly as you say. A second conversation is created. Please file an issue and I'll take a look at it.
-
2. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
luksa Nov 6, 2012 9:34 AM (in response to luksa)Ah, yes. When the <form> tag is rendered, the conversation hasn't been started, since ConvTest hasn't been instantiated yet (and @PostConstruct hasn't been invoked yet). As a result, the action url of the <form> tag contains no cid parameter, because there's no conversation active when the url is generated.
Need to figure out what, if anything, we should do about this.
-
3. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
lucaster Nov 6, 2012 9:53 AM (in response to luksa)Thanks for the clarification!
As a matter of fact, the side effect also occurs when the outputText is after the </h:form>
-
4. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
luksa Nov 6, 2012 9:57 AM (in response to lucaster)1 of 1 people found this helpfulYes, of course. The key thing here is that the conversation must be long-running before rendering the starting form tag.
Basically, the main problem with your approach is that you are starting the conversation in the render-response jsf phase. Ideally, you should start the conversation before this phase, otherwise the urls in html will not have the cid parameter, which is necessary for propagating the conversation.
-
5. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
mkouba Nov 6, 2012 10:23 AM (in response to luksa)I think you might also use <f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/> inside the commandButton provided you have the outputText before commandButton. But Marko is right that this approach is not convenient...
See also my blog post about ajax-related issues you might encounter: Seam vs Weld: ajax and conversations in JSF view
-
6. Re: Two conversations created instead of one with conversation.begin() in @PostConstruct method
tony.herstell1 Nov 6, 2012 5:40 PM (in response to mkouba)Going with KISS...
I land on a page via a menu that calls an "init" function in a controller...
// A good place to START a conversation from. ** land here off a menu // click... public String init() { this.logger.info(">>>init"); if (!this.conversation.isTransient()) { this.logger.info("Existing conversation found:" + this.conversation.getId() + " Ending it..."); this.conversation.end(); } this.logger.info("+++CONVERSATION START"); this.conversation.begin(); // START THE LONG RUNNING CONVERSATION this.logger.info("conversation:" + this.conversation.getId()); this.setupXXXXValues(); this.logger.info("<<<init"); return "pretty:manageXXXXs"; }
and yes Buttons need the cid applied (especailly if you use prettyfaces)
<ui:fragment rendered="#{xxxManagementController.CRUDMode eq 'DELETE'}"> <p:commandButton id="deleteButton" update=":xxxxForm:xxxxxPanel :messagesForm" icon="ui-icon ui-icon-disk" action="#{xxxxManagementController.deleteXxxx(xxxxx)}" value="#{messages.button_delete} #{messages.xxxx}" onstart="return confirm('#{messages.are_you_really_sure}')"> <f:param name="cid" value="#{xxxxxxManagementController.cid}" /> <!-- FORCE ConverstionId to be added --> </p:commandButton> </ui:fragment>
//Tell prettyfaces to use this bean when the pattern matches and show the manage xxxx page. Also support a Query Param (cid). @URLMappings(mappings = { @URLMapping(id = "manageXXXs", pattern = "/xxxx/manage", viewId = "/pages/xxxx/manageXxxx.xhtml"),
Keeps it very simple though and avoida a lot of problems with Conversation Handling in JEE 6 Weld.