1 Reply Latest reply on Dec 26, 2007 3:48 PM by Arbi Sookazian

    best practices with Seam and presentation logic

    Arbi Sookazian Master

      So I have a use case where I need to reset the selected value of the h:selectOneMenu. I am using the following code to tracke the old and new values:

      <h:form id="peerForm">
       <h:selectOneMenu id="selectPeer" value="#{peerAction.employeeId}" valueChangeListener="#{peerAction.processValueChange}">
       <a4j:support event="onchange"
       onchange="Richfaces.showModalPanel('mpChangePeer',{width:450, top:200})"/>
       <f:selectItems value="#{peerAction.peers}" />
       </h:selectOneMenu>
       </h:form>



      SFSB:


      private String selectedValue;
      
      private String oldValue;
      
      public void processValueChange(ValueChangeEvent value) {
       selectedValue = (String)value.getNewValue();
       oldValue = (String)value.getOldValue();
       }



      I know from previous post that Pete had stated it's bad practice to handle presentation logic in a session bean (which I won't argue with although it does get confusing when SFSB's are essentially backing bean for JSF's).

      The two options are:

      1) to use Seam remoting to access the old value from client side and reset selected value via javascript.

      2) reconstruct the HtmlSelectOneMenu component in a POJO/SFSB.

      What is the recommended best practice according to Seam framework regarding this situation???