• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

problem in excluding the parameter in validation interceptor

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic