aspose file tools*
The moose likes Struts and the fly likes problem in excluding the parameter in validation interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in excluding the parameter in validation interceptor" Watch "problem in excluding the parameter in validation interceptor" New topic
Author

problem in excluding the parameter in validation interceptor

rajiv shrestha
Ranch Hand

Joined: Aug 25, 2010
Posts: 30
my action file is:

package action;

import com.opensymphony.xwork2.ActionSupport;

public class SampleAction extends ActionSupport{

private static final long serialVersionUID = 1L;

public void validate()
{
System.out.println("validate() method called");
}

public String populate()
{
System.out.println("populate() method called");
return "populate";
}

public String execute()
{
System.out.println("execute() method called");
return SUCCESS;
}
}



in struts.xml:

<action name="*Sample" method="{1}" class="action.SampleAction">
<interceptor-ref name="defaultStack">
<param name="validation.excludeMethods">populate</param>
</interceptor-ref>
<result name="populate">/first.jsp</result>
<result name="success">/success.jsp</result>
</action>


i think the output must be:

populate() method called
validate() method called
execute() method called

but it gave

validate() method called
populate() method called
validate() method called
execute() method called

i am trying to to validate only during execution of exclude() method.

------ need help ------
thnx in advance
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi Rajiv Shrestha Welcome to JavaRanch

You can use to skip validation for a particular method.
In case of validation using xml file, using <actionClass>-<actionAlias>-validation.xml naming we can make the validation to work only for a particular method.

You struts.xml file configuration for excluding validation for methods also differs from struts2 documentations.


A.A.Anbarasu
Rajkumar Kathiresan
Greenhorn

Joined: Dec 30, 2008
Posts: 8
Hope you misunderstand the concept of Interceptors. Interceptors are called before and after the execution of the method.
And its the exact syntax for excluding the method from validation
<param name="excludeMethods">populate</param>
otherwise you can use the solution suggested by "Anbarasu"

let me know if you need any assistance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in excluding the parameter in validation interceptor