9.9. Redirecting to a natural conversation
When initiating or redirecting to a natural conversation, there are several ways to specify the natural conversation name. You can start with the following page definition:
<page view-id="/auction.xhtml"> <param name="id" value="#{auctionDetail.selectedAuctionId}"/> <navigation from-action="#{bidAction.placeBid}"> <redirect view-id="/bid.xhtml"/> </navigation> </page>
Here that invoking
#{bidAction.placeBid} redirects you to /bid.xhtml, which is configured with the natural conversation ID PlaceBid. Your action method declaration looks like this:
@Begin(join = true) public void placeBid()
When named conversations are specified in the
<page/> element, redirection to the named conversation occurs as part of navigation rules following the invocation of the action method. This can cause problems when redirecting to an existing conversation, as redirection needs to occur before the action method is invoked. Therefore, the conversation name must be specified before the action is invoked. One method of doing this uses the <s:conversationName> tag:
<h:commandButton id="placeBidWithAmount" styleClass="placeBid" action="#{bidAction.placeBid}"> <s:conversationName value="PlaceBid"/> </h:commandButton>
You can also specify the
conversationName attribute for either the s:link or s:button:
<s:link value="Place Bid" action="#{bidAction.placeBid}" conversationName="PlaceBid"/>