struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Mohan <rahul.mo...@tcs.com>
Subject Re: Partial Validation
Date Wed, 28 Apr 2010 05:58:37 GMT
Thanks for your comments Wes.

I do have different action methods which I am invoking through wild-card 
mappings. But I do not want to repeat the same validations in page level 
submits and partial submits. I have implemented another solution with a 
little bit of S2 customization.

- Introduced a new annotation to group fields on the action class. For 
example:
         @Group("CustomerAddress") private int cityCode;

- Introduced a group validation annotation to validate fields of only one 
group from the class. Example:
        @Validate("CustomerAddres")
        public String saveAddress() {
                ............
        }

- Implemented a GroupValidatorManager extends 
AnnotationActionValidatorManager (S2 internal) and introduced that instead 
of the AnnotationValidationManager in struts xml as the default bean:
<bean name="default"  type=
"com.opensymphony.xwork2.validator.ActionValidatorManager" 
                class="com.tcs.gui.arch.validation.GroupValidatorManager" 
/>

- GroupValidatorManager overrides the getValidator to return only the 
applicable validators for the current method by processing the 
annotations.

I can share this code if anyone is interested.

- Rahul



From:
Wes Wannemacher <wesw@wantii.com>
To:
Struts Users Mailing List <user@struts.apache.org>
Date:
27-04-2010 21:12
Subject:
Re: Partial Validation



When you submit the fieldset through ajax, are you submitting to a
different action mapping? If the ajax submit and the full form submit,
you could setup a validation for the action mapping that corresponds
to the ajax submit. Handling ajax validation is a bit tricky, but
somewhere in the wiki, there is a document that describes it.

-Wes

On Wed, Apr 21, 2010 at 3:35 AM, Rahul Mohan <rahul.mohan@tcs.com> wrote:
> Hi,
>
> Is there any way I can do a partial validation in Struts 2? I have a 
page
> with two fieldsets, where I can either submit the entire page or submit
> only the fieldset (through Ajax). In the latter case, I wish to validate
> only the fieldset's properties, but in the former case I want the entire
> page to be validated. I am using annotation for validation.
>
> Regards,
> Rahul
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message