File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation with dispatch action

 
Ramakrishna Bysani
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am using dispatch action in my project. I am using ValidatorForm for server side validation. In my action i have getInput, getMaster, getModel methods are there. getInput results in displaying the input screen by populating all drop downs.
I dont want validation to be triggered when i am calling getInput method. How to avoid this? Currently i achieved by putting code in form like this.

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
logger.debug("Validating ....");
ActionErrors errors = null;
if(!getMethod().equalsIgnoreCase(METHOD_INPUT_NAME)){
errors = super.validate(mapping, request);
}
return errors;

}

Is there any better way to achieve this? some thing like declarative in some config file? Please help me, thanks in advance
 
Ramakrishna Bysani
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any one there to help me
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Validation Framework has some obvious drawbacks when using DispatchAction, the principal one being the one you've experienced: You can't apply different validations for different methods of the same Action class. I'd say the solution you've posted is as good as any.
 
Ramakrishna Bysani
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merrill.
I have finished my work with the same code
I was on vacation and could not see your message, sorry for late reply.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic