View Full Version : Is there any good way to display success message.
daigo
Sep 21st, 2006, 08:47 PM
I'm searching class that is similar to struts' ActionMessage. I can display error message easily because of Errors interface. But I can't do same way about success message(s).
Should I have to set success message hand by hand?
gmatthews
Sep 26th, 2006, 07:54 PM
I think this is actually a (very rare) short coming in Spring.
I think Errors should have been called Messages and provided some sort of parameterised message level, e.g. Error, Warning, Info, similar to logging.
We've done just that, and pass a Messages interface into the service layer from our controllers, and let the service + business layers populate Messages with message keys + message levels.
These are then published into Errors or our own session based object for publishing in JSP pages. We use a session since messages then survive redirects. The JSP panel responsible for displaying any info messages then clears the session based message store.
There's probably a better way but this seems to work ok for us.
daigo
Sep 27th, 2006, 12:26 PM
Thank you for replying. Your Messages interface way is exactly what I need.
And I completely agree with your opinion about shortcoming in Spring. Is it already posted in jira?
By the way, how about tag library about Messages? Do you create it your self?
gmatthews
Sep 27th, 2006, 07:03 PM
Its nothing very complicated, and no its not in Jira.
public interface Messages {
void addMessage(String key, MessageLevel level);
void addMessage(String key, Object[] params, MessageLevel level);
Iterator<Message> getErrors();
boolean isEmpty();
boolean isErrors();
Iterator<Message> getInfoAndWarnings();
}
daigo
Sep 29th, 2006, 08:05 AM
I posted jira. http://opensource.atlassian.com/projects/spring/browse/SPR-2657
I'm using spring web flow with jsp, so I have to create some message interface helper method to action that extends FormAction and tag libraries.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.