Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in excluding the parameter in validation interceptor

 
rajiv shrestha
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajkumar Kathiresan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic