0 Replies Latest reply on Apr 25, 2012 2:52 PM by Jean-Noel Colin

    Problems disabling dependent component

    Jean-Noel Colin Newbie

      Hello

       

      Although this seems to be a basic use of RichFaces 4.2.1, I can't get it to work. I have a checkbox bound to a Request-scoped bean's boolean variable; when unset, I want to disable the following inputText; when set, I want to have it enabled. Note that the form contains other fields which require other validation (in particular some required fields)

       

      My understanding is that I have to do a partialSubmit on the checkbox using a4j:ajax, and re-render both components; here's the way I do it:

       

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

        columnClasses="registerColumn1,registerColumn2,registerColumn3">

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

        <h:selectBooleanCheckbox id="groupRegistration"

        value="#{visitorBean.groupRegistration}"

        valueChangeListener="#{visitorBean.groupRegistrationValueChangeListener}">

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

        </h:selectBooleanCheckbox>

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

       

        <h:outputLabel id="numParticipantsLabel" for="numParticipants"

        value="Number of participants" />

        <h:inputText id="numParticipants"

        disabled="#{!visitorBean.groupRegistration}"

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

        requiredMessage="Required field" converter="javax.faces.Integer"

        converterMessage="Invalid number">

        </h:inputText>

        <rich:message id="numParticipantsMsg" for="numParticipants"

        ajaxRendered="true" />

        </h:panelGrid>

       

      When I set the checkbox, the inputtext gets enabled; the issue is that when I enter data, and submit the form through a a4j:commandButton (invoking an Action method on the bean), the model value doesn't get updated, just as if the inputtext was not enabled on the backend.(actually, I'm pretty sure that the problem comes from the fact that the field in the backend is still disabled, and thus not updated upon form submission)

       

      What did I get wrong? How can I achieve this?

       

      Thanks for your help

       

      Jean-Noël