2 Replies Latest reply: Apr 26, 2012 11:13 AM by Jean-Noel Colin RSS

    disabling/enabling component with ajax not working

    Jean-Noel Colin Newbie

      Hi

       

      I have a simple form with three fields; one checkbox and two text fields, one of which should be enabled when the checkbox is ticked. Using the <a4j:ajax> tag, I'm able to enable/disable it on the UI side, but on the backend side, the component is always disabled, which means that the request value are never set, don't get validated and don't get to the model. Here the code I'm using; the first component is the checkbox, the second is the text field to be disabled and the third is a simple textfield. If I tick the checkbox, the text field gets enabled, but when I submit the form, the value is always set to 1 (the default value). Could anyone help me with solving this?

       

      Many thanks

       

      Jean-Noël

       

       

        <h:panelGrid columns="3" styleClass="registerTable"

        columnClasses="registerColumn1,registerColumn2,registerColumn3">


        <h:outputLabel for="groupRegistration" value="Group registration" />

        <h:selectBooleanCheckbox id="groupRegistration"

        value="#{registrationBean.groupRegistration}"

        valueChangeListener="#{registrationBean.groupRegistrationValueChangeListener}">

        <a4j:ajax render="@this,numParticipants"></a4j:ajax>

        </h:selectBooleanCheckbox>

        <rich:message for="groupRegistration" ajaxRendered="true" />

       

        <h:outputLabel for="numParticipants" value="Number of participants" />

        <h:inputText id="numParticipants"

        disabled="#{!registrationBean.groupRegistration }"

        value="#{registrationBean.numParticipants}" width="5"

        converter="javax.faces.Integer" converterMessage="Invalid number">

        </h:inputText>

        <rich:message for="numParticipants" ajaxRendered="true" />

       

        <h:outputLabel for="firstName" value="Firstname" />

        <h:inputText id="firstName" value="#{registrationBean.firstName}"

                                              width="20">

        </h:inputText>

        <rich:message for="firstName" ajaxRendered="true" />

       

        </h:panelGrid>