File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Can't get error messages to display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can Watch "Can New topic
Author

Can't get error messages to display

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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

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: 436
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't get error messages to display
 
Similar Threads
Blank page returned from ActionForm
How can I have global and specific html:errors?
Formatting the Errors
getXXX error?? for XXXX
validation of indexed properties