I was doing this because I have a series of pages that work sort of like a wizard. On the first page the user enters some initial values. Depending upon the values entered warning messages may need to be displayed on later pages in the flow.
I didn't think it was too non-standard a practice to store messages in the session using something like: request.getSession().setAttribute("streamedit-messages", messages); since the html:messages tag allows for a name field and that's the session attribute key for the messages. <html:messages id="msg" name="streamedit-messages" bundle="timetablingResources"> <li><bean:write name="msg"/></li> </html:messages> I was surprised to see that only the "standard" ActionMessages get cleared out after they have been displayed. Since the name="something" facility was there, I thought somebody might be using it and I wondered how they were clearing up after themselves. I've had a bit of a think over the weekend and reworked it so that now the Java uses: messages.add("streamedit", message); this.saveMessages(request.getSession(), messages); and the JSP uses: <html:messages id="msg" message="true" property="streamedit" bundle="timetablingResources"> <li><bean:write name="msg"/></li> </html:messages> and it all works as I would like it with the messages being cleared after being displayed once. I just have to be careful that none of the intermediary pages between where the message was added and where it is to be displayed just does a generic display of every message (which is no great hardship). Cheers, Kevin > -----Original Message----- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper > Sent: Saturday, 9 September 2006 6:52 a.m. > To: user@struts.apache.org > Subject: Re: Session scope ActionMessages > > Kevin Maeer wrote: > > Hi, > > > > I'm using ActionMessages stored in the session to display > messages on a page and > > everything works splendidly except that the messages never > get removed from the > > session so every time the user re-enters the page old > messages get redisplayed. > > After a bit of digging around, this appears to be because I > am using my own keys > > (instead of Globals.MESSAGE_KEY and Globals.ERROR_KEY) so > the RequestProcessor's > > processCachedMessages method doesn't clear out the messages. > > > > How have other people got around this? Is the > simplest/cleanest option to > > subclass RequestProcessor and override the > processCachedMessages method to > > remove any attribute that is an instance of ActionMessages > and that has > > isAccessed() = true? > > > > We're using Struts 1.2.7. > > The simplest options would seem to be not to store messages in a > non-standard place, so the standard clean-up will work... If you can > explain why you're doing that, maybe we can suggest an > alternative approach. > > Failing that, your solution sounds like it should be workable -- > provided you have a fixed / constrained set of session scope keys to > clean up. > > L. > > > --------------------------------------------------------------------- > 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]