wood burning stoves 2.0*
The moose likes Struts and the fly likes how would I check if there are errors in Action execute method 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 "how would I check if there are errors in Action execute method" Watch "how would I check if there are errors in Action execute method" New topic
Author

how would I check if there are errors in Action execute method

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Within my execute method I wish to check if there are errors i.e. if the form was not fully completed

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
DynaValidatorForm registrationForm = (DynaValidatorForm)form;

if(no errors)
return (mapping.findForward("success"));
else
return (mapping.findForward("failure"));

thank you for your time
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
DynaValidatorForm registrationForm = (DynaValidatorForm)form;
ActionErrors errors = new ActionErrors();

// add some errors if something bad happened

if(!errors.isEmpty())
return (mapping.findForward("success"));
else
saveErrors(request, errors);
return (mapping.findForward("failure"));


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how would I check if there are errors in Action execute method
 
Similar Threads
Multiple buttons in a form
struts, error reporting
DynaValidatorForm question:
Confused on validate() method
Populating a form