I got some problems understanding the Conversation scope of Weld or CDI.
In my JSF Faclets page i call:
-
Short answer: Yes, this is the correct behavior.
Long answer: A conversation represents a "unit of work", which a such has to be demarcated explicitly. This is done with the explicit call of conversation.begin() - as you are doing already. Should you want to use the same conversation over more than one request, you have to propagate it - this is what you are not doing :-)
When you propagate a conversation, a conversation-id is appended to the request. This tells the container which conversation is wanted. When you just hit the refresh button without a conversation-id in your request a new conversation is generated for each request.
From the documentation:
The conversation context automatically
propagates with any JSF faces request
(JSF form submission) or redirect. It
does not automatically propagate with
non-faces requests, for example,
navigation via a link.
If you need to propagate it manually, just add the conversation-id to the request:
<h:link outcome="/addProduct.xhtml" value="Add Product">
<f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/>
</h:link>
All that and much more is explained here.
讨论(0)
- 热议问题