So I tried the following code but still same. What I am doing wrong.
1. Inside action class
InfoForm iForm = (InfoForm)form;
Integer age = iForm.getNumber();
if(age<21){
ActionErrors formErrors = new ActionErrors();
formErrors.add("age", new ActionMessage("age.error"));
saveErrors(request, formErrors);
return mapping.findForward(DENY);
}else{
ActionMessages formMessages = new ActionMessages();
formMessages.add("age", new ActionMessage("age.ok"));
saveErrors(request, formMessages);
return mapping.findForward(ALLOW);
}
2. In JSP
<font color="red"><html:errors /></font>
<font color="blue">
<html:messages id="age" message="true" >
<li><bean:write name="age"/></li>
</html:messages>
</font>
<html:form action="process">
Name: <html:text property="name"/><br/>
Age: <html:text property="number"/><br/>
<html:submit/>
</html:form>
On 11/2/2011 3:17 PM, Paul Benedict wrote:
The<html:message> tag has an 'message' attribute. Set that to true to
iterate over messages; set it to false to iterate over errors.
Paul
On Wed, Nov 2, 2011 at 2:14 PM, Anjib Mulepati<anji...@hotmail.com> wrote:
Hi All,
I have been using ActionErrors to display all kind of message from form
submission action. Problem with that is I have to display message using
<html:errors/> tag and I can't distinguish between success and failure
message.
I want to store error messages and success message in different object so
that I can display messages with proper formatting (red for error/blue for
success) back in the form page. I am not displaying new page after form
submission. User see there status in same form page.
Thanks,
Anjib