6 Replies Latest reply on Apr 5, 2007 5:36 AM by ilya_shaikovsky

    Using required="true" inside a tabPanel

    juanignaciosl

      Can I use required="true" somehow in a h:inputText inside a tabPanel? If I do, it stop moving around the tabs. It works if I put immediate="true" to the tabPanel, but if I do, a later commandButton won't work.

        • 1. Re: Using required=
          ilya_shaikovsky

          Please provide your code. I can't reproduce this on my simple examples.

          • 2. Re: Using required=
            nbelaevski

            Hello!

            That can happen if validation failed (eg. input text is empty). Do you have <h:messages /> somewhere on the page? Are there any?

            • 3. Re: Using required=
              ilya_shaikovsky

              And I hope you put some values to your required fields before switching?

              If you need to have input values as required only for the controls except tabs - do not wrap your whole tabPanel to form. Just wrap the content of the every tab. - switching will be available with empty fields but form submit - not.

              • 4. Re: Using required=
                juanignaciosl

                I'm afraid I can't send code until next Monday. I'll explain its structure and my objective:

                I have fields distributed on tabs. h:messages was outside tab group, which was inside a h:form (as documentation said). Te problem arises when you put required="true" on any field.

                Because of your comments I've realized I commited a silly mistake: if I put h:messages inside the tab it would've probably shown the message.

                I was thinking on letting the user move through the tabs without validating, which would be done in the final submission, but maybe it's more intelligent and usable validating each tab independly.

                Anyway, if you could tell me if I can do the other thing (validating only with a submission) it would be great.

                Thank you very much!

                • 5. Re: Using required=

                  If you have a h:messages, do not forget to surround it with a4j:outputPanel ajaxRendered="true". I.e:

                  <a4j:outputPanel ajaxRendered="true">
                   <h:messages />
                  </a4j:outputPanel>


                  Otherwise, the message is not appear during the ajax response if validation is failed.


                  • 6. Re: Using required=
                    ilya_shaikovsky

                    Simplier way to validate the whole tabPanel on submit but switch it without any validation - is using switchMode="client" for the tabPanel.