File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Multiple actionerror tags problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple actionerror tags problem" Watch "Multiple actionerror tags problem" New topic

Multiple actionerror tags problem

shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Hi Guys,

On one of my pages I have two forms and each for has <s:actionerror /> tag. The problem is if the action class returns an error, the error message is displayed on both actionerror tags. How can I set it so only the form being used outputs the error?
David Newton

Joined: Sep 29, 2008
Posts: 12617

Action errors are per-action, not per-form: as such there's only one collection of error messages--there's no way to differentiate them.

There are a few options. One would be to use pseudo-field errors, using a field name that doesn't actually exist in either form, and use the <s:fielderror...> tag, looking for the pseudo-field error. Another would be to just handle it manually.
I agree. Here's the link:
subject: Multiple actionerror tags problem
It's not a secret anymore!