Author
Can't get error messages to display
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
Hi, In my Struts application, I have my validateForm method in my ActionForm
public ActionErrors validate(
ActionMapping mapping, HttpServletRequest request ) {
final ActionErrors errors = new ActionErrors();
...
ActionMessage am = new ActionMessage("error.accountNum.invalid");
logger.debug("Validation failure:" + am.toString());
errors.add("accountNum",am);
and then on my JSP page I have
<div>
<html:errors></html:errors>
</div>
However even though my validation form is setting values in the ActionErrors object (which I verify through my log file), those errors are displayed in the JSP. Any ideas what I'm doing wrong?
Thanks, - Dave
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Feb 27, 2009 09:29:48
0
Are you calling validation manually? If so you need to save the errors to the request.
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
I am not calling it manually. I put the ActionErrors validate method to my ActionForm and have this in my struts-config.xml file
<form-beans>
<form-bean name="REAccountLookUpBean" type="com.myco.regui.struts.accounts.AccountsForm" />
</form-beans>
<action path="/pcFlow"
type="com.myco.regui.struts.accounts.AccountsAction"
scope="request"
name="REAccountLookUpBean"
validate="true"
input="/jsp/pcAccountLookup.jsp">
</action>
The method is getting called just fine and the ActionErrors object is getting set but nothing is displayed for "<html:errors></html:errors>". Why not?
- Dave
subject: Can't get error messages to display