• 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

DynaValidatorForm question:

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic