wood burning stoves 2.0*
The moose likes Struts and the fly likes DynaValidatorForm question: 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 "DynaValidatorForm question:" Watch "DynaValidatorForm question:" New topic
Author

DynaValidatorForm question:

James Drinkard
Greenhorn

Joined: May 30, 2002
Posts: 19
Hello All,
I'm converting a simple simple form application to use the DynaValidatorForm and I believe I have the plugins and xml files configured properly. My question is: how do I code for the validation in the action class? My code is:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
DynaValidatorForm f = (DynaValidatorForm) form;
System.out.println(f.toString());
//ActionErrors errors = new ActionErrors();

ActionErrors errors = f.validate(mapping, request);
System.out.println(errors);

// Report any errors we have discovered back to the original form
if (!errors.empty())
{
saveErrors(request, errors);
return new ActionForward(mapping.getInput());
}

// Forward control to the specified success in the struts-config.xml file.
return (mapping.findForward("success"));
}
but ActionErrors never get thrown, even though I use "required" to check for null fields on the submit from the jsp form.

Not sure what I have wrong here.
Thanks,
James
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: DynaValidatorForm question:
 
Similar Threads
Validation
Validation
how would I check if there are errors in Action execute method
Confused on validate() method
problem getting data from form bean