6 Replies Latest reply on Aug 19, 2009 5:01 PM by jamesjmp

    Is it possible to validate a "region" of components?

    coresystems_rit

      Hi


      Is it possible to validate a region of components directly with seam?


      I have a situation where I have several components in one form. It is not possible to split up those elements in multiple forms. In the same form there are two input fields as well as a s:link. On the s:link pressed, a method in the backing bean gets called. This methods takes the two other input fields and does some stuff.


      Now the problem or my wish would be, that I can define what should get validated when one executes the s:link. As not the whole form should get validate only those two input fields.


      Is this possible with a direct approach or do I have to validate the fields in the backing bean?


      Thanks for your answers
      Thierry

        • 1. Re: Is it possible to validate a "region" of components?
          niox.nikospara.yahoo.com

          Hello,


          Do you need to use the <s:link>? Suppose you used <a:commandLink> as follows:


          <!-- the components to be validated -->
          <h:inputText id="alpha" .../>
          <h:inputText id="beta" .../>
          
          <!-- the link -->
          <a:commandLink
            action="#{your.action}"
            ajaxSingle="true"
            process="alpha,beta"
            reRender="..."
          />
          



          Clicking this link would cause a partial submit, with only alpha, beta being processed. JSF would validate only these components and call your method only if both are valid. Note: this would require you to have registered validators (JSF or Seam) on these components! Moreover, you may skip the update model phase by specifying bypassUpdates="true".

          • 2. Re: Is it possible to validate a "region" of components?
            coresystems_rit

            Hi Nikos


            Thank you for your answer. As we are using ICEfaces as UI framework we do not have the ajax4jsf components. Therefor we can't use the command link from there. But this way would be a solution to our question.


            Is there somehow an seam or icefaces component with the same functionality like a:commandLink?


            Thanks for your answers and help,


            Thierry

            • 3. Re: Is it possible to validate a "region" of components?
              jguglielmin

              Several different things come to mind.  It depends on the actual layout of your view page though.  Keep in mind that you can use the partialSubmit property set to true and a validator property to specify a method for validation for each of the ICEfaces input components.  You can also access any other input in the same context to do validation between various inputs.  If the other input components are empty, then the validation is not triggered for them with partialSubmit.  Otherwise, the partialSubmit submits the entire form (I am assuming that this is what you are trying to get away from).  If you aren't using a container which must be encased within a form, then you could simply break the input area into various forms.  You could also use popupPanel (which exist in a form outside the original form) to do the validation.  You could use iframes, etc....For more assistance on this type of thing, you might want to consider the ICEfaces forum where there would be much more of this type of thing listed (examples even!).

              • 4. Re: Is it possible to validate a "region" of components?
                coresystems_rit

                Hi Judy


                Thanks for your answer. We also came across the partialSubmit solution, but we sometimes expected a race condition between the partialSubmit and a commandLink with the immediate flag set to true. I've posted about that in the ICEfaces forum.


                I will search again in the ICEfaces forum, perhaps I'll find something i haven't found yet about this topic :-)


                Thanks for your help!


                Thierry

                • 5. Re: Is it possible to validate a "region" of components?
                  jguglielmin

                  Are you using partialSubmit and immediate properties on the same input component?  They are used for diverse behaviour, so wouldn't recommend doing so. As for using the ICEfaces forums, there is a section there pertaining to Seam and ICEfaces questions that is checked by ICEfaces staff much more often than is this forum (for obvious reasons).

                  • 6. Re: Is it possible to validate a "region" of components?

                    As we are using ICEfaces as UI framework we do not have the ajax4jsf components. Therefor we can't use the command link from there. But this way would be a solution to our question.
                    Is there somehow an seam or icefaces component with the same functionality like a:commandLink?


                    Hi Thierry:
                    I´ve never used Icefaces, but AFAIK no matter whether you are using IceFaces or Richfaces, you may use in both cases Ajax. Keep in mind Richfaces and Icefaces (and others..) are libraries that provide you with widgets and features, but none of them prevent you from using Ajax. In fact, Ajax is for you to be used whenever you need to in xhtml views.
                    So in your ui:composition add this and feel free to use ajax :


                        xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"