• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation not showing up

 
Frederick Smythe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a tile which contains a form upon which I want to perform some simple validation. Originally I had a problem whereby it would correctly display the validation errors, but the rest of the page would not be displayed correctly because no parameters were being passed along. To solve this I call this method within my ValidatorActionForm:

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
//Get standard validation errors
ActionErrors errors = super.validate(mapping, request);
if (errors == null) return null;
return errors;
}

This is called by the following code in my BaseAction's execute method so that if there are errors it is redirected to the correct page:

ActionErrors errors = emailForm.validate(mapping, request);
// if there are validation errors
if (errors != null && !(errors.isEmpty()))
{

// set path to URL of original page
String propertyDetailParams = emailForm.getPropertyDetailsParams();
// new ActionForward for reloading original page
RedirectingActionForward backForward = new RedirectingActionForward(mapping.findForward("invalid"));
backForward.addParam("propertyId", propertyDetailParams);
request.setAttribute(Globals.ERROR_KEY, errors);
return backForward;
}

This redirects properly back to the correct page but no validation errors are shown; it's as though the send button was never pushed. However I have the correct <html:errors/> within the jsp tile and I know the validation works correctly on other pages.


Does anyone have any thoughts or suggestions? If you need any more info I'll happily provide it.

Cheers.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like this is a Struts question. Moving this to the Struts forum on your behalf.
 
Frederick Smythe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic