s:link conversation propagation "none", page parameters
kipod Sep 1, 2009 11:19 PMHello all.
I have a situation in which a <s:link propagation="none"> does not leave the current long-running conversation.
I should mention right off the start that the view id the link leads to has a <begin-conversation join="true"> in its page descriptor in pages.xml.
My goal (simple - I'm a newbie):
You view available products on the productList.xhtml page which is backed up by an EntityQuery<Product>. The page has a search mechanism. You enter search criteria, click search
and postback to the same page seeing results. You can click a product's name and be taken to its productDetails.xhtml
page. When there, you can click a cancel
button, and return to the productList.xhtml
page - and if any search criteria was previously entered - it will appear as entered.
My way about it is to start a long-running conversation when you click the search
button at productList.xhtml
. Also, I wish to leave this conversation upon clicking a product's name and going to view its details - in order to encapsulate the user's action there in a different, new, conversation.
I don't want to use conversation nesting, because the parent conversation may end (the user clicks on a clear
button for resetting search criteria) and the child one would still need to be intact.
On productList.xhtml
, the conversation is upgraded to a long-running one upon clicking the search button, and it is made temporary again when you click clear
:
<h:commandButton id="search" value="#{messages['search']}" > <s:conversationPropagation type="join" /> </h:commandButton> <s:button id="clear" value="#{messages['clear']}" action="#{productList.clear}" propagation="end" />
(I'm using an h:commandButton because I want the form to be submitted, and there is no action
attribute because I wish to postback on the current page - I'm using EntityQuery's RESTRICTIONS - and it all works fine).
Still in productList.xhtml
, this is the link to go view a specific product's details:
(surrounded by a dataTable with a valid data model of products, where var="_prd")
<s:link id="productName" value="#{_prd.name}" view="/productDetails.xhtml" propagation="none"> <f:param name="productId" value="#{_prd.id}"/> </s:link>
The productDetails.xhtml file is backed up by a EntityHome<Product>, and also works fine. It has the following descriptor:
<page view-id="/productDetails.xhtml"> <begin-conversation join="true" flush-mode="manual"/> <param name="productId" value="#{productHome.id}" converterId="javax.faces.Long" /> </page>
I want to start a long-running conversation upon entering the page - the page can actually be accessed from many different places in the application.
Thing is - I want it to be a new separate conversation from existing ones, yet I am using join="true" because I have ajax validation on the page, e.g. :
<s:decorate id="nameField" template="layout/edit.xhtml"> <ui:define name="label">#{messages['name']}</ui:define> <h:inputText id="name" required="true" value="#{productHome.instance.name}"> <a:support id="onblur" event="onblur" reRender="nameField" /> </h:inputText> </s:decorate>
If I remove the join="true" from productDetails.xhtml's descriptor - I get an exception due to the app trying to start a long-running conversation where one already exists - that's why the join="true" is there.
The cancel
button on productDetails.xhtml
:
<s:button id="cancel" value="#{messages['cancel']}" view="/productList.xhtml" propagation="end" />
And the bottom line:
If your'e in the productsList.xhtml
page and enter some search criteria and click search
, the results are shown and the conversation indeed becomes a long-running one.
BUT - if you then click on a product's name and go to view its details, the propagation="none" doesn't hold and when entering productDeatils.xhtml
Seam will not start a new separate long-running conversation, but join the existing one.
This leads to a situation where when you click cancel
in the productDetails.xhtml
page, the conversation is of course ended, and it is the conversation that held the sought after search criteria...
Any advice would be great! Thanks.