6 Replies Latest reply on Mar 11, 2009 10:06 AM by swd847

    required=true: If and only if "Save" button is clicked

      Hi!
      My problem that required=true blocks any attempted communication with the server until satisfied,it does not matter if its a plain old submit or a modern richfaces AJAX based request, if a required=true is somewhere in the page it will block it...


      How to deal with that? how to tell it that it should only block stuff if and only if I am clicking the Save button?


      Or should I just deprecate the use of requiered=true as a legacy solution no longer compatible with AJAX?


      Regards,

        • 1. Re: required=true: If and only if "Save" button is clicked
          diegocoronel

          Hi Francisco,


          if i understood what you want i think your solution is ajax:region, something like:



          <a4j:region>
            <h:input 
                required=true
                xxxxx>
                <a4j:support .... some ajax here/> // instead of a4j:region you can use ajaxSingle=true here
            </h:input>
          </a4j:region>
          <h:input
              required=true
              yyyyyy
          </h:input>
          
          <h:button value=save.../>


          • 2. Re: required=true: If and only if "Save" button is clicked
            joblini

            Are you using ajaxSingle="true"?

            • 3. Re: required=true: If and only if "Save" button is clicked

              Yes but a4j:region does not work, because I am using rich:tab in switchType mode ajax. For example (in pseudo code for brevity):


              <rich:tabPanel switchType="ajax">
              
              <rich:tab label="First">
                 <h:selectOneMenu required="true">
                        <s:selectItems noSelectionLabel="Select one..."/>
                 </h:selectOneMenu>
              </rich:tab>
              
              <rich:tab label="Other">
                  Other Stuff
              </rich:tab>
              
              <rich:tabPanel>
              
              



              So I can not switch from tab First to tab Second unless I select something in the h:selectOneMenu with the required="true" and if I add regions (one inside each tab, and when that didn't work one around all the tabPanel):


              <rich:tabPanel switchType="ajax">
              
              <a:region>
              <rich:tab label="First">
                <a:region>
                 <h:selectOneMenu required="true">
                        <s:selectItems noSelectionLabel="Select one..."/>
                 </h:selectOneMenu>
                <a:region>
              </rich:tab>
              
              <rich:tab label="Other">
                <a:region>
                  Other Stuff
                <a:region>
              </rich:tab>
              
              <rich:tabPanel>
              <a:region>
              
              



              I does not help at all, seems like regions are useless for this... Any other suggestions?

              • 4. Re: required=true: If and only if "Save" button is clicked
                joblini

                Do you have a single form, around all the tabs, or do you have a form inside each tab?

                • 5. Re: required=true: If and only if "Save" button is clicked

                  Single form... why?

                  • 6. Re: required=true: If and only if "Save" button is clicked
                    swd847

                    I have been bitten by this many times in the past. required=true and ajax does not play well together. I have been considering trying to create a page tag that allows for conditional requiredness, something like:



                    <h:inputText value="#{a}" >
                       <s:required value="button1,button2" />
                    </h:inputText>




                    That would have the effect of only making the control required if the form was submited by components button1 or button2. All the existing workarounds such as ajaxSingle have serious limitations.