2 Replies Latest reply on Mar 30, 2010 2:56 AM by shanika Dias

    Conversation ends but new changes arn't reflected from DB

    shanika Dias Newbie
      Hi,


      I'm having a list and a view. The list displays list of records and view to modify the selected record from the list. Upon click on save button on view page application must redirect back to the list showing the updated record along with other records in datatable.

      Which means, the save button must :
            1- Save the record to DB
            2- Requery to load the list of records from DB and show in the list page (showing the modified record with latest values).


      The issue is that, the modified values are not displayed. The requery stil returns the old records. The worst is that until I open a new browser and requery the new changes arn't relfected in the list page (eventhough the changes have gone to the DB).

      I use 2 stateful session beans, one to update record(in a long running conversation) and the other that queries the list.

      Upon redirecting to the list page I call the query method so that the new values must be shown. I do this via the pages.xml since if I call requery in the update method, the query() will be in the same conversation. So I first end the Conversation and then call the query() upon loading of the list page (so that they are in two conversations).

      In pages.xml :
      ,
      <rule if="#{XX.referrer == '/showList.xhtml'}">                    
                          <end-conversation before-redirect="true"/>                                   
                          <redirect view-id="/showList.xhtml"/>                    
                          
                     </rule>
      '

      '
      <page view-id="/showList.xhtml">

      <action execute="#{xxx.query}"
                      if="#{XX.referrer == '/showList.xhtml'}"
                      on-postback="false"/>
                     
      </page>
      '

      In update method :

        @End (beforeRedirect=true)
         public void modifyRecord() {
          ....
          em.flush();

      }

      Is this due to objects are still held in Conversation Scope though the Conversation has ended? How to clear the objects so that new values are shown? Can someone pls help?

      thanks
      Shanika
        • 1. Re: Conversation ends but new changes arn't reflected from DB
          Bernard Labno Master

          Have you checked on debug if query gets executed after update?
          As to me the condition blocks it :


          <action execute="#{xxx.query}"
              if="#{XX.referrer == '/showList.xhtml'}"
              on-postback="false"/>
               </page>



          If you redirect from i.e. '/details.xhtml' then it will not be fired.


          For sure objects from conversation where you do the update are not transfered over redirect (before-redirect=true).


          Do you use conversation for browsing the list also? If so, than it is a bad habit (session, and thus memory usage, rows rapidly). It does not cost that much to retrive 20 records from database each time (provided you do not fetch images from DB).

          • 2. Re: Conversation ends but new changes arn't reflected from DB
            shanika Dias Newbie
            Hi Bernard,

            Yes, my query method does get executed but still displays the old data.

            No, I don't use a specific conversation for querying. What I meant was when @End is specified, it must end the current long running conversation.  What I wanted was to make sure that the above issue wasn't due to having the same long running conversation when querying the list back.    According to my understanding, @End switches  to a temporary conversation (as there is always a conversation involved).

            Now I have removed all of the above "action execute="#{xxx.query}"
            ..." part from pages.xml and am using a factory method (@Factory) for the query method so that it must automatically display the latest results list upon updating a record and loading the list page. But still it gives the old data and untill I open a new browser window I cannot get the changes reflected being in the same browser (session).

            Any idea why? Please help.