1 Reply Latest reply on Jan 23, 2010 1:50 AM by Iov Gherman

    s:link End conversation before redirect

    Iov Gherman Newbie

      I have a simple case:

      A list in which I display some records. The list is using an Event scoped bean. When I click a record (an s:link) I am calling a @Begin annotated method in an Conversation scoped bean so I am starting a new conversation. I am also entering into a new edit page. I am using that bean to edit the entity and I am updating some of the entity fields on the server (using some ajax requests).
      I have an s:link in the edit xhtml like this:

      <s:link propagation="end" view="myList.xhtml">Cancel</s:link>

      So I am trying to close the conversation and go back to the list without saving any changes I might did on the entity. When I am back in the list the entity fields are changed (like I was doing a save not a cancel). If I am doing any kind of refresh on the list then the entity is back to the state it should be (before doing any changes).
      The problem here is that the conversation is not closed yet and the list is getting the entity from the JPA cache, it is only closing after the redirect so next time I will take the data from the server I will get the right values. I know in java code I can use Conversation.instance().endBeforeRedirect(); to end the conversation before the redirect. I tried to use the s:link like this:
      <s:link action="#{myEditBean.cancel}" view="myList.xhtml">Cancel</s:link>

      and in myEditBean I created this method:

      public void cancel() {

      but I am having the same issue.
      I am using JPA and I am starting the Conversation with

      @Begin(flushMode = FlushModeType.MANUAL, join = false)
           public void begin() {

      Any opinion? Please tell me what I am missing here.
      Thank you