• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get error messages to display

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you calling validation manually? If so you need to save the errors to the request.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic