Interesting idea, I plan to try it... I've had occasional difficulties getting the built-in persistence methods to work just right. If I use flash, the message doesn't always survive the redirect, say if I return null from onSuccess().
But I'm curious about the original statement, "Generics are dangerous in SessionState, in fact, SessionState is dangerous with anything but a custom type." That's news to me, so I must be missing something. On Thu, Jan 6, 2011 at 11:38 AM, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > This looks like an application-wide problem, so I'd create a service that > stored the messages in the Session with two methods. One would get the > messages and removes them from the Session, remove them from the Session and > then return them. The other one would store these messages into the Session. > > > > On Thu, 06 Jan 2011 14:25:08 -0200, Pierce Wetter <pie...@paceap.com> > wrote: > > What's the best practice for pushing and displaying "flash" messages? >> It's easy enough for me to add an variable for this: >> >> @Persist("flash") >> List<String> messages; >> >> along with associated display HTML to my layout component, but then >> getting access to the current layout component from various places sounds >> tedious. Plus it probably wouldn't work anyways, because the flash >> persistence is by page & nested component id, and so on. So I guess that >> means SessionState. >> >> Naively, that would look like this: >> >> @SessionState(create=false) >> List<String> messages; >> >> Except Generics are dangerous in SessionState, in fact, SessionState is >> dangerous with anything but a custom type. So that means: >> >> @SessionState(create=false) >> Messages messages; >> >> With the Messages object wrapping the list. Presumably Messages has to be >> serializable. I would have to put an @AfterRender in whatever draws the >> messages to clear it. >> >> Seems simple enough, if tedious. But I was wondering if anyone had come up >> with a solution they were especially proud of. >> >> Pierce >> > > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate > Coordenador e professor da Especialização em Engenharia de Software com > Ênfase em Java da Faculdade Pitágoras > http://www.arsmachina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >