wood burning stoves 2.0*
The moose likes Struts and the fly likes how to use html:errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to use html:errors" Watch "how to use html:errors" New topic
Author

how to use html:errors

Sevika
Greenhorn

Joined: Sep 14, 2005
Posts: 2
Hi,
I am new in Struts. I want to display error message in view. For that, in my bean (ActionForm) I have written validate() method :-

ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = null;
if( name.equals("") )
{
errors = new ActionErrors();
errors.add("error_username", new ActionError("error.name.required"));
}
return errors;
}

In view I have wriitten "html:errors".
But it is not displaying me anything what else I have to do to show error messages.Can u tell me.

thanks.
A Harry
Ranch Hand

Joined: Jan 23, 2002
Posts: 124
you will need to have something along the lines of -

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

at the top of you page otherwise the "html" tag will be meaningless!
Sevika
Greenhorn

Joined: Sep 14, 2005
Posts: 2
hi A Harry,
That I have alredy included. Something else that I have to do. Do I have to mention something in struts-config.xml file.

thanks
vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
Hi,

Ya u need to specify in struts-config.xml as validate=true while declaring action tag. And be sure that error.name.Required is in ApplicationResources.properties. And place that properties file under WEB-INF\classes. Check it works.
[ September 14, 2005: Message edited by: vijaya bharath ]

Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use html:errors