5 Replies Latest reply on Oct 25, 2008 11:24 AM by valatharv

    Rendering/Disabling/Enabling components based on other compo

    trouby

      Hey,

      What is the easiest way to control components attributes (such as rendering/disable/enable/etc...) based on other components?

      for example, I want to render an input field only if a checkbox was selected,

      of course with ajax support :-)



      (Is it possible to be done only on the view side without java code?)



      Many thanks,

      Asaf.

        • 1. Re: Rendering/Disabling/Enabling components based on other c
          trouby

          Hey,

          Well I guess this can easily achieved by using the 'support' tag of RF,


          The problem is that if components affects others in a big form will only work if the form is correctly validated, otherwise JSF bypass the update model phase,

          And immediate=true bypass update model phase too,


          So in big forms where the form is not yet filled up, how can I skip validation but still update model phase?

          Myfaces has subForms which I think can help here,
          Is there any way to achieve this with RF?


          Thanks,

          Asaf.

          • 2. Re: Rendering/Disabling/Enabling components based on other c
            fabmars

            Question 1)
            Yes, this is pretty common in JSF. Just use some managed beans to set your submitted values and some EL expressions to provide a test in any rendered attibute you want. Use that with some A4J support tags and you're good.

            Question 2)
            Use the ajaxSingle attribute of most A4J/RichFaces components. You will bypass the whole form submission and perform only a partial submit, BUT you will pass thru the validation (only of what you're submitting) anyway.

            My advice is you check the online RF demo with galore souce examples.

            • 3. Re: Rendering/Disabling/Enabling components based on other c
              trouby

              Yap,

              'ajaxSingle' looks good for me (missed it somehow),


              Thanks FAbmars,


              Asaf.

              • 4. Re: Rendering/Disabling/Enabling components based on other c

                 

                "trouby" wrote:

                Myfaces has subForms which I think can help here,
                Is there any way to achieve this with RF?


                a4j:region is an analog for subform when we speak about the ajax request. It allows to process only the form element inside the a4j:region and ignore the outer data.

                ajaxSingle does the same, but for one particular form element.

                • 5. Re: Rendering/Disabling/Enabling components based on other c
                  valatharv

                  Hi,

                  I this is best place you can help, please suggest me on the following..

                  I have form field (h:inputText) which is disabled when the page loads.

                  Is there nice way just to enable h:inputText when user clicks "Edit This" link(it can be button also).

                  I don't want to use Javascript.........

                  <s:link value="Edit This" id="edit">

                  <s:decorate template="layout/edit.xhtml">
                  <h:inputText id="name" required="true" value="Test enable" disabled="true"/>
                  </s:decorate>