wood burning stoves 2.0*
The moose likes Struts and the fly likes ActionErrors with html:errors tag not displaying errors :-( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionErrors with html:errors tag not displaying errors :-(" Watch "ActionErrors with html:errors tag not displaying errors :-(" New topic
Author

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

Wendy Baur
Greenhorn

Joined: Mar 01, 2005
Posts: 13
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

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
Wendy Baur
Greenhorn

Joined: Mar 01, 2005
Posts: 13
I solved my own problem :-) I neglected to add the ApplicationResources.properties file to struts-config.xml.

Thanks for your suggestions.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionErrors with html:errors tag not displaying errors :-(
 
Similar Threads
Error: creating bean of class (HELP THE NEWBE)
html:errors
problem validating form fields in ActionForm......
ActionError
ActionMessages?????????