--- Robert Leland <[EMAIL PROTECTED]> wrote: > David Graham wrote: > > >--- Robert Leland <[EMAIL PROTECTED]> wrote: > > > > > >>[EMAIL PROTECTED] wrote: > >> > >>David, > >> > >> I thought you were going to back this out ? > >> > >> > > > >The conversation was left with me proposing a solution and asking for > >Martin's thoughts on it. He hasn't responded so I haven't backed it > out. > > > >Saving messages in the session is a commonly requested feature (and one > >that I need) so I think it needs a solution. > > > If the solution can automatically clean up after itself, no matter what > scenario that is thrown at it, then I am +1. > If there is *--any--* usecase where the session can be left with the > messages still in the session, then I am -1. > What ever goes into the session must be explicitly managed, which is > usually handled from > the struts-config.xml, such as the ActionForm lifecycle.
I know of two options: 1. Add a "remove" attribute to <html:messages> so it will remove the messages when it's finished rendering. 2. Use something like SingleUseActionMessages which will remain in the session until overwritten but will only return messages once. Option 1 wasn't popular under the tags-shouldn't-alter-session-state philosophy. Option 2 does leave the messages in the session but they're harmless after the first use. I don't care which one we go with but storing messages in the session *is* a needed feature so we do need a solution. David > > -Rob > > > > >Action.saveMessages() that > >saves them in the session is part of that solution. The other, is a > class > >I wrote called SingleUseActionMessages that only returns its messages > one > >time. I can commit SingleUseActionMessages if it's needed or we can > come > >up with a better solution. > > > >David > > > > > > > >>-Rob > >> > >> > >> > >>>dgraham 2003/08/19 16:20:46 > >>> > >>> Modified: src/share/org/apache/struts/action Action.java > >>> Log: > >>> Added version of saveMessages() that saves them into the session > >>> > >>> instead of the request. > >>> > >>> Revision Changes Path > >>> 1.67 +33 -8 > >>> > >>> > >>jakarta-struts/src/share/org/apache/struts/action/Action.java > >> > >> > >>> > >>> Index: Action.java > >>> =================================================================== > >>> RCS file: > >>> > >>> > >/home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v > > > > > >>> retrieving revision 1.66 > >>> retrieving revision 1.67 > >>> diff -u -r1.66 -r1.67 > >>> --- Action.java 2 Aug 2003 21:12:16 -0000 1.66 > >>> +++ Action.java 19 Aug 2003 23:20:45 -0000 1.67 > >>> @@ -431,15 +431,16 @@ > >>> > >>> } > >>> > >>> - > >>> /** > >>> * Save the specified messages keys into the appropriate > request > >>> * attribute for use by the <html:messages> tag (if > >>> * messages="true" is set), if any messages are required. > >>> > >>> > >>Otherwise, > >> > >> > >>> * ensure that the request attribute is not created. > >>> * > >>> - * @param request The servlet request we are processing > >>> - * @param messages Messages object > >>> + * @param request The servlet request we are processing. > >>> + * @param messages The messages to save. <code>null</code> or > >>> > >>> > >>empty > >> > >> > >>> + * messages removes any existing ActionMessages in the request. > >>> + * > >>> * @since Struts 1.1 > >>> */ > >>> protected void saveMessages( > >>> @@ -454,9 +455,33 @@ > >>> > >>> // Save the messages we need > >>> request.setAttribute(Globals.MESSAGE_KEY, messages); > >>> - > >>> } > >>> + > >>> + /** > >>> + * Save the specified messages keys into the appropriate > session > >>> + * attribute for use by the <html:messages> tag (if > >>> + * messages="true" is set), if any messages are required. > >>> > >>> > >>Otherwise, > >> > >> > >>> + * ensure that the session attribute is not created. > >>> + * > >>> + * @param session The session to save the messages in. > >>> + * @param messages The messages to save. <code>null</code> or > >>> > >>> > >>empty > >> > >> > >>> + * messages removes any existing ActionMessages in the session. > >>> + * > >>> + * @since Struts 1.2 > >>> + */ > >>> + protected void saveMessages( > >>> + HttpSession session, > >>> + ActionMessages messages) { > >>> + > >>> + // Remove any messages attribute if none are required > >>> + if ((messages == null) || messages.isEmpty()) { > >>> + session.removeAttribute(Globals.MESSAGE_KEY); > >>> + return; > >>> + } > >>> > >>> + // Save the messages we need > >>> + session.setAttribute(Globals.MESSAGE_KEY, messages); > >>> + } > >>> > >>> /** > >>> * Save a new transaction token in the user's current session, > >>> > >>> > >>creating > >> > >> > >>> > >>> > >>> > >>> > >>>--------------------------------------------------------------------- > >>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > > > > > >__________________________________ > >Do you Yahoo!? > >Yahoo! SiteBuilder - Free, easy-to-use web site design software > >http://sitebuilder.yahoo.com > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]