How to set the natural conversation parameter-value
thiagu.mr Aug 20, 2013 2:09 AMIn my project I have two pages.
One is like a product search page and the other one is like product detail page.
We are displaying the products from the search page by using data table.
The user can navigate to product detail page by clicking the view product detail link in the table row from search page.
When the user click the link from product search page, we are passing the selected product id as a request parameter to the detail page.
The product detail page displays, based on this selected product id parameter.
I want to implement the natural conversation in my product detail page, so I want this selected product id as conversation id for the product detail page.
this is my conversation definition from pages xml like below.
<conversation name="productId" parameter-name="pId" parameter-value="#{productIdFactory}"/>
The page xml definition for product search page is like below.
<page view-id="productSearch.xhtml">
<begin-conversation join="true" flush-mode="MANUAL" />
<action execute="#{productSearch.initAction}" on-postback="false" />
<navigation from-action="#{productList.gotToDetailsPage}">
<rule if-outcome="viewDetail">
<end-conversation before-redirect="true"/>
<redirect view-id="/productDetails.xhtml">
<param name="pId" value="#{productList.selectedPid}" />
</redirect>
</rule>
</navigation>
</page>
The page xml definition for product details page is like below.
<page view-id="productDetails.xhtml" conversation="productId">
<begin-conversation join="true" flush-mode="MANUAL" />
<action execute="#{productDetail.initAction}" on-postback="false" />
<param name="pId" value="#{productDetail.productId}" />
<navigation from-action="#{productDetail.gotToSearchPage}">
<rule if-outcome="backToSearch">
<end-conversation before-redirect="true"/>
<redirect view-id="/productSearch.xhtml"/>
</rule>
</navigation>
</page>
This is my sample code for view product detail link from product search page is like below.
<h:commandLink value="view detail" action="#{productSearch.gotToDetailsPage}">
<f:param name="pId" value="#{rowData.id}"/>
<s:conversationName value="productId"/>
</h:commandLink>
As per the natural conversation rule, the parameter-value needs to present in the current context.
In my case I don’t know how to keep multiple values in the context for the conversation parameter-value,
because the user can select any product from the product search page.
Can anyone provide help on how to implement the "productIdFactory", in my case?