Struts2 uses xwork validation. The best description of how it finds your xml files is here: http://www.opensymphony.com/xwork/wikidocs/Validation%20Framework.html Pay particular attention to the alias description in the "Defining Validation Rules" section because that's what's not working for you.

The best way to debug this validation issue is to install the xwork source and watch it as it searches for an xml file using the names it expects. I'm not sure what mistake you've made below. Instead I'm providing another working example:

REAL working example:
My action class is: my.package.ManageAccountAction
So my validation xml file is located in: my/package/

My action declaration is:
<action name="manageAccount!*" method="do{1}" class="my.package.ManageAccountAction">

and my submit button is:

<s:submit id="ChangeDetails" key="Change Details" action="manageAccount!ChangeCompanyDetails"/>

ie. on submit, it calls the the doChangeCompanyDetails method of the ManageAccountAction

So my validation file name is exactly:

ManageAccountAction-manageAccount!ChangeCompanyDetails-validation.xml

Yes - that definitely works. In your case it's likely you haven't got the alias quite right for your action and method.

Good luck.

PS. Note that the ! is purely optional and not to be confused with the struts1 bang notation.
PPS. None of this applies to annotation declared validation.

Vijay Prajapati wrote:
Hi,
I am using Struts2.0.6 and trying to implement Validator framework but
couldn't succeed. I have confution to give name of
actionname-validator.xmlfile.
I am here giving action cofiguration in Struts.xml

<action name="*UserManagementAction" method="{1}" class= "
com.realsoftinc.appcentral.web.user.UserManagementAction">
<interceptor-ref name="validationWorkflowStack" />
< result name="success">/adduser.jsp </result>
<result name ="input">/adduser.jsp</ result>
</action>
I have implemented UserManagementAction.java with 4
methods(addNew,Update,delete,execute) which return SUCCESS and INPUT. In
that i want validation in only 2 methods(addNew,Update).

If i would create UserManagementAction-validation.xml then validation is
executed for all 4 methods. but if i would create
UserManagementAction-addNew-validation.xml then it is not executed for
addNew method.

In my JSP there are 3 submit button with assigned method named
addNew,Update,delete.

So what should i do to execute validation for addNew and Update method?

Please Help me to solve this problem.

Vijay Prajapati

------------------------------------------------------------------------

No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.1/822 - Release Date: 28/05/2007 11:40 AM


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to