1 Reply Latest reply on May 14, 2007 6:39 PM by loopingrage

    A4J - Can I refresh a components value without applying the

      I'm knee deep in some Seam/A4J fun and have hit a road block. Is it possible to have A4J refresh the value of a component without going through Apply Request Values?

      The attached code demonstrates what I'm trying to accomplish. I'd like to see changes (made outside this form in a different browser) to a person's Manager ID by clicking the the refresh button (cmdRefresh). In a typical web application, I would just have my users refresh the page to view changes but since it's AJAX, I'm essentially looking for is a way to mark a component as read-only for a given AJAX request.

      Does this even make sense?

      
      
      <h:form id="DummyForm">
       <h:selectOneMenu id="lstDestination" value="#{BackingBean.managerId}" >
       <f:selectItems value="#{Util.selectItems}" />
       </h:selectOneMenu>
       <a4j:commandButton id="cmdRefresh" value="Refresh" reRender="lstDestination" />
       <a4j:commandButton id="cmdSave" value="Refresh" actionListener="#{BackingBean.save}" />
      </h:form>
      
      
      public class Person {
      
       private String name;
       private String phone;
       private Long managerId;
      
       public Long getManagerId() {
       return managerId;
       }
      
       public void setManagerId(Long managerId) {
       this.managerId = managerId;
       }
      
      }
      
      public class BackingBean {
      
       Person person;
      
       public void setManagerId(Long managerId) {
       this.person.setManagerId(managerId);
       }
      
       public Long getManagerId() {
       return this.person.getManagerId();
       }
      
      }
      


        • 1. Re: A4J - Can I refresh a components value without applying

          Here is the solution I came up with. The magic is in jsFunction's "bypassUpdates" attribute.

          <a4j:commandButton id="cmdRefresh" value="Refresh" reRender="lstDestination" />


          becomes

          <input type="button" value="refresh" onclick="getManagerId()" />
          <a4j:jsFunction name="getManagerId"
           data="#{BackingBean.managerId}"
           oncomplete="refreshManager(data)"
           reRender="lstDestination"
           bypassUpdates="true"
          />
          <script>
           function refreshManager(data) {
           document.forms[0].lstDestination.value = data;
           }
          </script>


          I hope this helps someone :)