0 Replies Latest reply on Sep 16, 2011 5:13 AM by jano480

    Conversation, propagation, 2 beans

    jano480

      Hello Weld Users,

      I have a question about conversation, how it works...
      I have 2 beans:


      @Named
      @ConversationScoped
      public class SearchBean implements Search, Serializable {
      ...
          @PostConstruct
          private void init() {
              logger.info("init search bean");
          }
      
          @Override
          public void search(ActionEvent event) {
              if (conversation.isTransient()) {
                  conversation.begin();
              }
              service.search(this.otherEvent);
          }
      ...
      }
      





      @Named
      @ConversationScoped
      public class ControlBean implements Search, Serializable {
      ...    
          @PostConstruct
          private void init() {
              logger.info("init control bean");
          }
      
          public void openDetail(ActionEvent event) {
              logger.info("openDetail");
              messages.info("openDetail");
          }
      ...
      }



      and 1 page with 2 forms:


      <h:form id="form1">
      ...
      <h:commandButton value="#{msg['lbl.btn.find']}"
          actionListener="#{searchBean.search}">
          <f:ajax render="@form" execute="@form"/>
      </h:commandButton>
      ...
      </h:form>
      <br/>
      <h:form id="form2">
      ...
      <h:commandButton value="#{msg['lbl.btn.oped.detail']}"
          actionListener="#{controlBean.search}">
          <f:ajax render="@form" execute="@form"/>
      </h:commandButton>
      ...
      </h:form>
      



        What happens after loading the page:
      • init search bean

      • init control bean

      • searching:init search bean...search event...starting conversation

      • init control bean



      I would now expect that both beans wont initialize until I end the conversation!
      But the problem is that after hitting opendetail the init control bean is executed, like it would not know about the conversation.


      The problem disappears if the whole page has only one form:both beans are in the same form.



        Questions:
      • Is it possible to propagate a conversation through jsf actionevent? And how?

      • I would like to have 2 forms because 1 ist only a search form, and second is only a control form, I select a row in the table, it represents an entity on which I perform the actions from control form...How can I achieve this?