struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siddiq Syed <>
Subject Re: query regarding Input Validation
Date Sat, 07 Nov 2009 18:51:48 GMT

From: gaurav nigam <>
To: Struts Users Mailing List <>
Sent: Sat, November 7, 2009 1:21:41 PM
Subject: Re: query regarding Input Validation

Hi Saddiq,
-- siddiq

Thanks for your help....
I am not able to understand meaning of below line
You can achive this by creating an separate file for each method you mean that i should create separate action class for each method
or you mean to say separate validation file for each method of an
action class...

--- Separate validation file for each action name speicifed in the struts.xml ,

By your suggestion, I need to create multiple action mappings in
struts.xml for each of the method of the action class....

Its not with the method of the actin class , its the action name what is been defined in the
-- For example if you have an action class user
public class UserAction extends action {
     public String addUser(){
        return success;
    public String modifyUser(){
        return success;

<action name="addUser"  class="UserAction" method="addUser">
    <result name="success'>somejsp.jsp</result>
    <result name="input">otherjsp.jsp</result>

<action name="modifyUser"  class="UserAction" method="modifyUser">
    <result name="success'>somejsp.jsp</result>
    <result name="input">otherjsp.jsp</result>

Validation files naming convection .

UserAction-addUser-validation.xml -- when user click on adduser --this validation file is
going to be invoked
UserAction-modifyUser-validation.xml -- when user click on modifyuser -- this validation file
is going to be invoked.

Note : this validation files need to be in the same package with action class.

Can we avoid this multiple action mappings by wildcard characters.....?

-- Yes we can avoid multiple action mapping. 

Please suggest your opinion.....

I am also waiting for some reply on Question 2 I have asked on earlier mail....
 Question 2 ?



On Sat, Nov 7, 2009 at 6:02 PM, Siddiq Syed <> wrote:
> You can achive this by creating an seprate file for each method and add the validation.
> When ever the a method from the action class is invoked the corresponding validation will get
> actionname-aliasname-validationname.xml
> actinname -- name of your actin class.
> aliasname -- name of the action specifed in the strust-xml file.
> <action name="x" class="com.yaction" method="x">
>      <result name="input" type="tiles">validationresult.jsp</result>
> </action>
> name of the validation file for the above mention action will be
> yaction-x-validation.xml -- where you can define the validation and will be invoke
when action x is invoked.
>  -Siddiq.
> ________________________________
> From: gaurav nigam <>
> To: Struts Users Mailing List <>
> Sent: Sat, November 7, 2009 12:14:32 PM
> Subject: query regarding Input Validation
> Hi All,
> I have a query regarding input validation.
> # Can we use method wise input validation in struts 2 ?
> if this is not supported directly, then is there any workaround for the same.
> #To utilise the xml based validation, I have to create different
> action class for same module is "user" and i had to
> create different action classes like adduser.action, modifyuser.action
> class etc...i have to do this as there are some fields which are
> different in each action....ideally i want to have single action class
> with different methods like add, modify, etc... to handle this..but
> can not do it so as same set of validation will be called for each
> method...which is not required in my case...
> After some search and study, i came to know that there is annotation
> validation which can be used and will be invoked per
> mentioned in this link
> but here, in need to hard code, my messages which i really want to
> avoid it, Is there any way to use property file here...please provide
> suggestion on this.....
> I have also learned that this annotation validation will not work for
> client side validation. Is there any work around for this....
> Kindly help me in this regard
> Thanks
> Gaurav
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

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