Struts errors/messages

R

Ryan Stewart

Another Struts question... If I have several messages/errors that I want to
display, using html:messages or html:errors, can I specify to display one
message in a particular spot and all the rest somewhere else? When I try
that, I get the one message where I want it, but in the "everything else"
area, the error shows up again. Is there a way to have it removed from the
ActionMessages collection when it is used or something like that?
 
S

Sudsy

Ryan said:
Another Struts question... If I have several messages/errors that I want to
display, using html:messages or html:errors, can I specify to display one
message in a particular spot and all the rest somewhere else? When I try
that, I get the one message where I want it, but in the "everything else"
area, the error shows up again. Is there a way to have it removed from the
ActionMessages collection when it is used or something like that?

What I do is something like this:

ActionErrors errs = new ActionErrors();
// for field-specific error
errs.add( "fieldName", new ActionError( ... ) );
// for global error
errs.add( ActionErrors.GLOBAL_ERROR, new ActionError( ... ) );

and in the JSP I do this to display global errors:

<html:errors property="org.apache.struts.action.GLOBAL_ERROR">

For the field-specific errors, I use this:

<html:errors property="fieldName">

I also did a search of the archives and found this same information,
courtesy of the same poster (me). Try it yourself next time... ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top