0 Replies Latest reply on May 31, 2007 12:18 PM by Roger Anderson Schmidt

    Multiple conversations from the same view-id

    Roger Anderson Schmidt Newbie

      First of all, I would like to say that the more I explore Seam and Icefaces, the more I marvel at their fantastic features. They are really a good job! Seam Conversations and Ice D2D concepts are brightly ideas.

      However, I think the integration between these two powerful frameworks is highly relevant and still deserves serious efforts. I've been using both components in a big project at my company for six months and I'm getting concerned about the hardly process to achieve stability during this period. Sometimes I don't know who I should ask for help. Like me, the users community is dreaming about make them talk to each other perfectly, as we can realize in the projects forum posts.

      Currently, for example, I am struggling with a strange situation at Icefaces v 1.6.0 DR#5 and Seam v. 1.2.1 GA (the latest ones at the moment).

      - I have two pages. One shows a selectable list of some kind of object (ListPage) and the other enables the edit of the selected one (EditPage).

      - By the way, my project is configured to use Seam Managed Persistence and Statefull Pageflow (JPDL).

      - To support the ListPage I have a SSB default scoped backing bean (FinderAction), that keeps DataModel, generates the query, and so on...

      - To support the EditPage I have a SSB conversation scoped backing bean (EditorActon), that "bijects" the entity bean selected from the list and allows to update him.


      It's simple to reproduce my main scenario:

      1. From the ListPage grid I select a object (alfa) via s:link to open in a New browser Tab.

      ** A long running conversation is created in a conversational scope (as I checked at seam debug page) and the conversation Id is rendered as a hidden input in the view (cid).

      2. From the same ListPage grid I select other object (beta) via s:link to open in another New browser Tab.

      ** New long running conversation and Id are created, too.


      The situations are:

      a) When I turn to the first EditPage (alfa object) and press any key at any input field, all the form hidden inputs are simply initialized by Icefaces bridge javascript (iceSubmit function: resetHiddenFieldsFor(aForm)).

      As a consequence, Seam "Manager.restoreConversation" doesn't get the correct one for "alfa" object, because the conversation ID parameter comes empty, and returns the ID associated to the last EditPage I've oppened (beta object).

      b) Then, after I disabled the invocation "resetHiddenFieldsFor(aForm)", the correct conversation context is recovered perfectly. But then I run into a second scenario:

      b.1) I confirm the update of the first object (alfa) and the action method is invoked.

      ** The correct conversation context is recovered, the entity is saved by EntityManager, the conversation is ended and the page flow is redirected back to the list.

      b.2) Then I turn to the second EditPage (for the "beta" object) and I confirm update action.

      ** But the action method isn't invoked anymore. Before give up, I've tried to go through the source and I checked ClientSideInterceptor wasn´t been invoked as it was in the first updating.

      That's the second weird situation. I'm not sure if it is a bug, anyway.


      Besides, the idea of using "named conversation ids" sounds great to me. If I had a possibility to create a business key as a identifier of object "bank" for example followed by the ID of the entity, I could have the same entity editing in different tabs, but using the same conversation, couldn't I ?


      Any help or hint is greatly appreciated.


      Thanks for the attention,


      Roger.



      Here are some code fragments:

      From FinderAction

      
       // seam managed persistence
       @In EntityManager entityManager;
      
       @DataModel
       private List<Banco> bancos;
      
       @SuppressWarnings("unchecked")
       public String find(){
      
       Query query = entityManager.createQuery("SELECT banco FROM Banco banco");
       bancos = query.getResultList();
      
       return null;
       }
      
       @Factory("bancos")
       public Object createBancos(){
       find();
       return bancos;
       }
      
       @Destroy @Remove
       public void destroy() {
       }
      


      From ListPage:
       <ice:column>
       <s:link value="Update" propagation="begin" pageflow="doEdit" action="prepareUpdate">
       <f:param name="entityId" value="#{row.id}" />
       </s:link>
       </ice:column>
      


      From EditAction:
       // seam managed persistence
       @In EntityManager entityManager;
      
       @Logger
       private Log log;
      
       @Out(required=false)
       private Banco banco;
      
       @RequestParameter
       private Long entityId;
      
       @In(required=true)
       private BancoFinderAction bancoFinderAction;
      
      
       public String prepareUpdate() {
      
       log.debug("prepareUpdate()");
      
       try {
       Banco temp = (Banco) entityManager.find(Banco.class, entityId);
       banco = entityManager.merge(temp);
      
       log.debug(banco.toString());
      
       } catch (Exception e) {
       e.printStackTrace();
       }
      
       return "prepared";
       }
      
       public String update() {
      
       log.debug("update()");
      
       try {
       log.debug(banco.toString());
       entityManager.flush();
      
       bancoFinderAction.find();
      
       } catch (Exception e) {
       e.printStackTrace();
       }
      
       return "updated";
       }
      
       @Destroy @Remove
       public void destroy() {
       }
      


      From EditPage:
       <ice:form>
       <ice:panelGroup>
      
       <ice:outputLabel for="code" value="Code*" />
       <s:decorate>
       <ice:inputText id="code" value="#{banco.codigo}" required="true" size="8" maxlength="3" />
       <br />
       <s:message />
       </s:decorate>
      
       <ice:outputLabel for="nome" value="Name* " />
       <s:decorate>
       <ice:inputText id="nome" value="#{banco.nome}" required="true" size="35" maxlength="30" />
       <br />
       <s:message />
       </s:decorate>
       <br/>
      
       <h:commandLink value="Save" action="ok" />
       <h:commandLink immediate="true" value="Cancel" action="cancel"/>
      
       </ice:panelGroup>
       </ice:form>