This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use html:errors

 
Sevika
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic