5 Replies Latest reply on May 15, 2008 1:01 AM by infinity2heaven

    Beginning and ending a conversation with same method

    System Administrator Expert

      Seam 2.0.1
      RF 3.2.0


      I have a drop-down (h:selectOneMenu) in a JSF with a SFSB with conversation scope.


      <h:column>
      <h:selectOneMenu id="seltech" value="#{assignInvToTech.selectedTech}" valueChangeListener="#{assignInvToTech.processValueChange}"> 
           <f:selectItems           id="techList"      value="#{assignInvToTech.techniciansList}"/>
           <a4j:support           event="onchange"      ajaxSingle="true"  reRender="errmsg, tempcompid,tempmsg"/>
      </h:selectOneMenu>
      </h:column>



      @Begin(join=true)
           public List<SelectItem> getTechniciansList() {          
                
                techniciansList = techniciansLoader.getTechniciansList();
                
                return techniciansList;
                
           }



      Is there a config for the @Begin annotation such that the annotated method begins and ends (alternating repeatedly) a conversation?


      If not, how can I accomplish this? 


      For example, when the user selects a different technician in the drop-down, I want the existing conversation to end and a new one to begin.


      thx.

        • 1. Re: Beginning and ending a conversation with same method
          infinity2heaven Novice

          Can you first describe, what your complete use case is? Forget about seam for a moment, and we can discuss if you really need a conversation to accomplish this.


          As for @Begin, @End for the same, I think that is redundant as it's the same as having a SFSB with conversation scope and a single method (without any @Begin). In the absence of a long-running conversation (multiple action methods spanning within a conversation scoped bean), Seam will create a temporary conversation for the purpose of serving a single request.

          • 2. Re: Beginning and ending a conversation with same method
            System Administrator Expert

            Inventory manager selects a technician from drop-down, enters a barcode into inputText for a hardware item.  a4j component fires and inserts a record into dataTable (which can be removed by clicking remove button for each row).


            User repeats for x hardware items for the same technician.  clicks submit button or cancel button to end conversation.


            To implement this use case, the SFSB must be conversation-scoped with @Begin/@End demarcated methods or session-scoped.


            There is an alternate path use case in which the user does the above and then decides he's doing it for the wrong technician.  So instead of forcing user to hit cancel button to end the conversation and start fresh, I want to have the conversation restart when user selects a different technician from drop down.

            • 3. Re: Beginning and ending a conversation with same method
              infinity2heaven Novice

              What are you functionally expecting after a conversation is restarted in your context? Again, I think you're thinking in terms of Seam's features as against your requirement. Have you tried it without a begin/end first? And see if it suits your req?

              • 4. Re: Beginning and ending a conversation with same method
                System Administrator Expert

                All the fields/instance variables in the SFSB need to be set to null when they select a different item in the drop-down.


                If I don't use Begin/End, then the data will be cleared after each request/response cycle.  This would break the requirement of being able to assign multiple hardware items to a single technician.


                That data is being maintained in a list/dataTable...

                • 5. Re: Beginning and ending a conversation with same method
                  infinity2heaven Novice

                  This is what I understand.
                  1) user selects from listbox
                  2) enters text in a seperate textbox. clicks add
                  3) data table populates
                  Repeats 2-3 4) user changes selected item and expects screen to clear values.


                  If that's the case, what does your processValueChange look like?


                  Try this, my first guess.


                  Change the getTechnicalList to a @Factory (See seam examples). processValueChange does nothing (in my case)


                  
                  @In @Out
                  
                  private Technician selectedTechn
                  
                  
                  @DataModel
                  
                  private List<TechnicianDataTableBean> 
                  
                  
                  @Factory
                  
                  public List<Technician> getTechnicalList() {
                  
                    // em.createQuery("from Technician");
                  
                  }
                  
                   
                  
                  @Begin(join=true)
                  
                  public void processValueChange () {
                  
                    // strange, but do nothing!
                  
                  }
                  
                  
                  
                  public void add() {
                  
                     // logic to rebuild data in the datatable
                  
                  } 
                  
                  
                  @End
                  
                  public void cancel() {
                  
                   // NO OP
                  
                  }
                  
                  
                  @End
                  
                  public void submit() {
                  
                   // save
                  
                  }




                  Let me know if this works