1 Reply Latest reply on Aug 20, 2013 2:13 AM by thiagu mariappan

    How to set the natural conversation parameter-value

    thiagu mariappan Newbie

      In 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?

        • 1. Re: How to init the natural conversation parameter-value
          thiagu mariappan Newbie

          after debug the seam core libs, I come to know the s:conversationName

          tag is passing the request param with name as "conversationName" and value as "pid:{product_id}".

           

          so i changed view product detail link from product search page is like below.

           

          <h:commandLink value="view detail" action="#{productList.gotToDetailsPage}">

          <f:param name="pId" value="#{rowData.id}"/>

          <f:param name="conversationName" value="pId:#{rowData.id}"/>

          </h:commandLink>

           

          now the natural conversation is working as expected.


          But the Long running conversation(LRC) for my search page is not getting end based on my navigation rule.

          because of the "conversationName" request parameter, seam is not able to restore the my search page LRC in the RESTORE view phase.

          so it creates new temporary conversation and invoke the "gotToDetailsPage" action, then it redirects to the product detail page with the new natural LRC.

           

          so i think seam doest not support the natual conversation, if my source page is in LRC. is it true?

           

           

          if i remove the following request parameter

           

          <f:param name="conversationName" value="pId:#{rowData.id}"/>

           

          in the view product detail link from the search page, i can end the search page LRC after redirect to detail page and i can start new natural LRC for the detail page without any issue.

          But if some try to start the same natural conversation in the new browser tab by clicking the same view detail link, seam throws following exception.

           

          IllegalStateException,  Conversation id is already in use: product_id

           

          any suggestion how to resolve this issue?