0 Replies Latest reply on Feb 1, 2008 4:49 AM by Jeroen Kruithof

    No rerendering when changing disabled fields

    Jeroen Kruithof Newbie

      Hi,

      My problem is :
      On a page are some required fields.
      When submitting the page jsf is giving an error message (correctly) .
      If you then select (in the small example below) the same person.
      It should fill the fields sex and date of brith en disabled them.

      This is not working.

      If you don't submit the page directly it all works fine.

      What is the problem?

      <f:view>
       <h:form>
       <h:messages></h:messages>
      
       <a4j:region renderRegionOnly="false">
       <h:selectOneMenu id="inputPerson"
       required="true"
       value="#{testHandler.person}">
       <f:selectItem itemLabel="choose" itemValue="-1"></f:selectItem>
       <f:selectItem itemLabel="Same person" itemValue="S"></f:selectItem>
       <f:selectItem itemLabel="Other" itemValue="O"></f:selectItem>
       <a4j:support event="onchange"
       action="#{testHandler.doVullen}"
       reRender="inputSex, inputBirthDate">
       </a4j:support>
       </h:selectOneMenu>
       </a4j:region>
      
       <h:selectOneRadio id="inputSex" required="true"
       disabled="#{testHandler.isSame}"
       value="#{testHandler.sex}">
       <f:selectItem itemLabel="Male" itemValue="M"></f:selectItem>
       <f:selectItem itemLabel="Female" itemValue="F"></f:selectItem>
       </h:selectOneRadio>
      
       <h:inputText id="inputBirthDate" size="10" maxlength="10"
       required="true"
       disabled="#{testHandler.isSame}"
       value="#{testHandler.birthDate}">
       </h:inputText>
      
       <h:commandButton value="submit"></h:commandButton>
      
       </h:form>
      </f:view>
      



      public class TestHandler {
      
       public String person;
       public String sex;
       public String birthDate;
      
      
       public String getPerson() {
       return person;
       }
       public void setPerson(String person) {
       this.person = person;
       }
      
       public String getSex() {
       return sex;
       }
       public void setSex(String sex) {
       this.sex = sex;
       }
      
       public String getBirthDate() {
       return birthDate;
       }
       public void setBirthDate(String birthDate) {
       this.birthDate = birthDate;
       }
      
       public String doVullen() {
       if ("S".equalsIgnoreCase(person)) {
       sex = "M";
       birthDate = "01011975";
       }
       if ("O".equalsIgnoreCase(person)) {
       sex = "F";
       birthDate = "01011980";
       }
       return "";
       }
      
       public boolean getIsSame() {
       return "S".equalsIgnoreCase(person);
       }
      
      }