Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionErrors with html:errors tag not displaying errors :-(

 
Wendy Baur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

When I attempt to display my ActionErrors (created in the validate method) I get the <li> </li> tags (dot) but, the error message is not displayed.
I checked the classes directory to ensure that the application.properties file was there and it is.....HELP

(please excuse the typo's my development machine is not on a network that is connected to the Intranet so, I have to type everything (sigh) in)

APPLICATION.PROPERTIES
errors.header=<ul>
errors.prefix=<li>
errors.suffix=</li>
errors.footer=</ul>
# -- validation errors --
error.username="You neglected to enter the user name."
error.password="You neglected to enter a password."
error.both="You neglected to enter a username and password."

ACTION FORM VALIDATION METHOD:
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest)
{
ActionErrors error = new ActionErrors();

if((getUserName() == null || getUserName().length() < 1 || getUserName().equals("")) && ((getPassword() == null || getPassword().length() < 1 || getPassword().equals("")))
{
error.add("both", new ActionError("error.both"));
}
else if((getUserName() == null || getUserName().length() < 1 || getUserName().equals(""))
{
error.add("userName", new ActionError("error.username"));
}
else if((getPassword() == null || getPassword().length() < 1 || getPassword().equals(""))
{
error.add("password", new ActionError("error.password"));
}
return error;
}

HTML DISPLAY CODE
<p><html:errors/></p>


Thanks sooooooo much for your help :-)
Wendy
[ March 09, 2005: Message edited by: Wendy Baur ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want quotes around the error messages in your properties file ("You neglected to enter the user name."). Try taking these out and see if it helps. Also, in your struts-config.xml, make sure that validate is set to "true" for this action.
[ March 09, 2005: Message edited by: Merrill Higginson ]
 
Wendy Baur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my own problem :-) I neglected to add the ApplicationResources.properties file to struts-config.xml.

Thanks for your suggestions.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic