Murali , Apologies its not exactly interceptors, Two ways we can validate
the input fields , one is using the configuration set for each of the
fields and the other is programatic way.

For example say we need to create a validation xml for user login, we
create User-validation.xml (Format is Action-validation.xml for different
classes). I just referred few inbuilt validators in the struts 2 site and
below are the ones


   -

     required validator.
    -

     requiredstring validator
    -

     int validator
    -

     date validator
    -

     expression validator
    -

     fieldexpression validator
    -

     email validator
    -

     url validator
    -

     visitor validator
    -

     conversion validator
    -

     stringlength validator
    -

     regex validator

   And these dont require registration when you are using them in your
   application. Just add the action validation xml to the classes directory.
   It works


<!DOCTYPE validators PUBLIC
        "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "
http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
<validators>
    <field name="userName">
        <field-validator type="requiredstring">
            <message>Username is required</message>
        </field-validator>
    </field>
    <field name="password">
        <field-validator type="requiredstring">
            <message>Password is required</message>
        </field-validator>
    </field>
</validators>

This is one of the easiest solutions to isolate the most commonly used
validations for the fields using configuration in struts2.

Hope this helps. Thanks

On 25 March 2013 16:25, Muralidhar Yaragalla <java.yaraga...@gmail.com>wrote:

> Hi can you explain in brief how to do with interceptor(built in)?
>
>
> On Mon, Mar 25, 2013 at 2:13 AM, Pranava Swaroop
> <stalin.pran...@gmail.com>wrote:
>
> > It could be done with buit in interceptors using configuration files or
> > using the programming
> >
> > On Monday, 25 March 2013, Muralidhar Yaragalla wrote:
> >
> > > Hi In my form i have 4 textfields with the same name so how do i
> validate
> > > this using validation frame work. The validation for this 4 fields is,
> > out
> > > of 4 fields 2 fields are mandatory and no field should contain special
> > > characters. So can this be done using validation frame work or do i
> have
> > to
> > > do custom valiation in my validate()  method inside action class.
> > >
> > > --
> > > Thanks And Regards,
> > > *Muralidhar Yaragalla.
> > > *
> > >
> >
> >
> > --
> > Keep looking Don't Settle
> >
>
>
>
> --
> Thanks And Regards,
> *Muralidhar Yaragalla.
> *
>



-- 
Warm Regards
Pranava S Balugari

"Keep Looking Don't Settle"

Reply via email to