*
The moose likes Struts and the fly likes validation with dispatch action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation with dispatch action" Watch "validation with dispatch action" New topic
Author

validation with dispatch action

Ramakrishna Bysani
Greenhorn

Joined: Sep 29, 2004
Posts: 10
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


Thanks,
Ramki.
-------------------------------------------------------
SCJP 1.4
SCWCD 1.4
Ramakrishna Bysani
Greenhorn

Joined: Sep 29, 2004
Posts: 10
Any one there to help me
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Ramakrishna Bysani
Greenhorn

Joined: Sep 29, 2004
Posts: 10
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.
 
jQuery in Action, 2nd edition
 
subject: validation with dispatch action
 
Similar Threads
ActionErrors or ActionMessages ?
struts validation
Using Struts Validator &
Validator
Behaviour on failure of validate in form bean