5 Replies Latest reply on Sep 14, 2012 5:09 AM by Martin Kouba

    How to Reload the conversation with the flushed data from data base using s:link

    Kishi kiran Newbie

      Hi I am new to seam and jsf 1.2, 

       

      In our application when i click the menu bar items, for each menu bar item one new conversation is started,

      when i click one of the menu item and going through sub pages(dataTable information) in the application.

      url its maintaining some cid and some paremeters, mean while from the mule i have processed some xml files which isareled to the sub pages, so xml files is updating some records in the data base,

      from the UI i  have a refresh button in sub pages, when i click the refresh button i need to to populate the updated data which was updated or flushed by the xml files, but i need to stay in the same sub page(data Table)

      so finally the data table has to reload with the new data.

       

      for  this I tryed to create the new conversation, but at that time when i click the refresh button the data table information is empty, *(in the URL its showing like conversationPropegation= begin, but remaining parameters are not maintained).

       

      so can any one give me a solution how to rebgin/ reload the conversation when i click refresh link, and how to populate the updated data and also maintain the same url parameters like cid.

       

      <s:link id="refreshId" view="/view/execution/executionPlanDetail.seam" propagation="none"></s:link>

       

      and also do i need to create any new conversation in pages.xml file ?

       

      Thanks in Advance!

        • 1. Re: How to Reload the conversation with the flushed data from data base using s:link
          Martin Kouba Master

          Hi,

          if I undestand your use case correctly you have menu with links, each link begins a new long-running conversation and redirects user to some page with dataTable (e.g. executionPlanList). Meanwhile some background operation may change the displayed data. So you need to refresh the data showed on the page. Is this correct?

           

          Well, I wouldn't create a new conversation. Simply reload the data in the current conversation. Add a refresh method to the conversational component that handles subpage actions/data, and use:

           

          1) <s:link> or <s:button> with action="#{component.refresh}" and without propagation="none" (the conversation id is propagated automatically)

          2) ajax component like RichFaces <a4j:commandLink> with action="#{component.refresh}" and rerendering the datatable (the conversation id should be propagated automatically, if not try adding <s:conversationId/>)

           

          HTH

          • 2. Re: How to Reload the conversation with the flushed data from data base using s:link
            Kishi kiran Newbie

            Hi Martin, Thanks for reply

            you understood what exactly I need.

             

            I have tried first one like

            <s:link action="#{component.refresh}" view="/view/execution/executionplans.seam">

                 <h:graphicImage value="/images/header_images/images/refresh.png"/>

            </s:link>

            and with out view attibute  it is giving some error like

             

            16:59:56,069 ERROR [Exceptions] handled and logged exception

            javax.el.PropertyNotFoundException: Target Unreachable, identifier 'component' resolved to null

                at org.jboss.el.parser.AstValue.getTarget(AstValue.java:38)

                at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)

                at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

                at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)

                at org.jboss.seam.navigation.Pages.callAction(Pages.java:704)

                at org.jboss.seam.navigation.Pages.preRender(Pages.java:331)

                at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:560)

                at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:471)

                at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:147)

                at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:117)

                at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)

             

            Target Unreachable, identifier 'component' resolved to null - please try again (Application error).

             

            in the browser url:

            before click refresh

            glog/view/execution/executionPlanDetail.seam?executionPlanUniqueId=_1312960876&executionPlanId=14&equipmentID=Container0313&cid=6#

             

            after refresh:

            /glog/error.seam?cid=15

             

            and in the 2nd way

             

            <a4j:commandLink action="#{component.refresh}">

                    <h:graphicImage value="/images/header_images/images/refresh.png"/>

            </a4j:commandLink>

             

            it does not give any error and no change in URL, still the datatable is  not getting updated.

             

            is that correct what i modified in the xhtml file? or do i need to chage any thing more apart from xhtml.

            • 3. Re: How to Reload the conversation with the flushed data from data base using s:link
              Martin Kouba Master

              Sure you need . Sorry, I was a little bit unclear . You have to replace component in #{component.refresh} with the name of your own Seam component that performs the refresh (e.g. fetch the data from the database) and of course implement this method (as I wrote above). This component probably holds the dataTable data already.

              • 4. Re: How to Reload the conversation with the flushed data from data base using s:link
                Kishi kiran Newbie

                Hi I have tried either way, like..

                 

                <s:link action="#{logit.ui.executionPlanBean.refresh}" view="/view/execution/executionplans.seam">

                         <h:graphicImage value="/images/header_images/images/refresh.png"/> </s:link>

                 

                but its giving error   : Method not found: com.logit.ui.execution.ExecutionPlanBean@1859ae.refresh() - Please try again

                 

                Here the scenario like, i have a main menu tab, when i click the new conversation begin and in that page i have a datatable which is geting populated with new data changes,(the data changes/updations wil happend through xml files)

                so insted of clicking my main menu tab i have placed a refresh link to populate the updated data in the datatable,

                here ExecutionPlanBean is my class which is in conversation scope, in this i have a mehtod like getExecutionPlansForCompany(){...} which is populating the DataTable data,

                 

                so when I tried like this

                <s:link action="#{logit.ui.executionPlanBean.getExecutionPlansForCompany()}" view="/view/execution/executionplans.seam">

                <h:graphicImage value="/images/header_images/images/refresh.png"/></s:link>

                 

                then when i click the refresh button, its populating the data without errors, and mean while i have processed one xml files which is to create a new row on the datatable,

                then i click button now the new row is populated and then i have processed another xml which is to update some columns in the existing data of datatable, then i click refresh now it does not work, updated columns data is not populated.. this is my problem

                 

                and one thing when i click the main menu tab in the url like

                 

                http://localhost:8080/glog/view/execution/executionplans.seam?conversationPropagation=begin

                 

                when i click the refresh url is changed

                 

                http://localhost:8080/glog/view/execution/executionplans.seam?actionMethod=view%2Fexecution%2Fexecutionplans.xhtml%3Alogit.ui.executionPlanBean.getExecutionPlansForCompany%28%29&cid=32

                 

                is that the right way to refresh the component, what i did here?

                 

                And also another scenario is like when i click one of the column in the datatable, it opens another page and which is also having datatable ,

                 

                URL like this when click one of the column:   http://localhost:8080/glog/view/execution/executionPlanDetail.seam?executionPlanUniqueId=_463760699&executionPlanId=35&equipmentID=EQDDD50&cid=32

                 

                so in this page also i have placed another refresh link, that will also work like reload the content of that table which is related to that perticular column datatable data.

                 

                Can you please give some example of component refresh extenally, while it is in conversation scope.

                • 5. Re: How to Reload the conversation with the flushed data from data base using s:link
                  Martin Kouba Master

                  Method not found: com.logit.ui.execution.ExecutionPlanBean@1859ae.refresh()

                  If you don't implement the refresh method, it's not there and this error makes sense.

                   

                  Data update is not propagated: this might be JPA and extended persistence context issue. For example if you use Seam managed persistence context within conversation the context is extended and lives even after the transaction completes. So if you execute the same query you get the results from the first level cache (aka Hibernate Session). You can try to call EntityManager.clear() in the getExecutionPlansForCompany() method right before the data are loaded. It's a kind of workaround but should work...

                   

                  URL change - ok, it's expected behavior.

                   

                  What I recommend you is to go through Seam 2 examples in download bundle.

                  1 of 1 people found this helpful