6 Replies Latest reply on May 11, 2007 4:18 PM by hstang

    Simple question with ajax4jsf

      I have a simple requirement to display an input-textbox when a checkbox is selected using ajax4jsf. There are other controls also in this form. The problem I'm running into is when I select the checkbox, thereby calling the a:support event='onclick' reRender='displayTextbox', it would not work because other controls on the form is not passing validation properly (i.e. those with controls that has required='true').

      How do I by-pass all those other validations on the form to simply just toggle displaying of my input-textbox?

        • 1. Re: Simple question with ajax4jsf
          fernando_jmt

          Have you tried surrounding your input-checkbox with <a4j:region>?

          • 2. Re: Simple question with ajax4jsf

            I'm not sure what region does. Looking at the documentation, I'm still a bit confused by the usage of region. What does it exactly do?

            • 3. Re: Simple question with ajax4jsf

              region limits the part of the component tree that will be processed (validation and update model phases). In your case, if you surround the input-textbox with region, other fields of the form will be ignored (bypassed) on the server. I.e. it is exactly what you desire to have.

              • 4. Re: Simple question with ajax4jsf

                I tried putting region around my input-textbox but validation still fires for the other fields. Here is my example code.

                <h:form>
                
                 <s:validateAll>
                
                 <s:decorate>
                 <h:inputText value="#{foo.dob}" required="true"/>
                 </s:decorate>
                
                 <h:selectBooleanCheckbox value="#{foo.nameSelected}">
                 <a:support event="onclick" reRender="namePanel"/>
                 </h:selectBooleanCheckbox>
                
                 <a:outputPanel id="namePanel">
                 <s:decorate>
                 <a:region>
                 <h:inputText value="#{foo.name}" rendered="#{foo.nameSelected}"/>
                 </a:region>
                 </s:decorate>
                 </a:outputPanel>
                
                 </s:validateAll>
                
                </h:form>
                
                


                • 5. Re: Simple question with ajax4jsf

                  you need to surround with a:region the part that you want to be processed, but not the part you do not want. I.e. you need to surround h:selectBooleanCheckbox in the code above.

                  • 6. Re: Simple question with ajax4jsf

                    Thanks Sergey,

                    That seems to work!