I finally figured out how to handle Ajax events and sessions from the @XHR annotation. It involved Thiago's suggested SessionState object, but as a means of communicating between the annotation worker and the session state tracker. The session state tracker turned out to be pretty complex, unfortunately. I will try to get the results posted on the wiki along with other integrations that I had to go through.
Thanks for your help! On Sep 19, 2011, at 1:00 AM, Lenny Primak wrote: > I finally had a chance to try these methods, unfortunately with little > success. > > Yes, I can check only one @Persist field for null to see whether the session > still exists, which works. > Request.getSession(false) does not really work, because a new (empty) session > can be created > within this request by other parts of the code, which is correct behavior. > > I tried the @XHR method as well, but I could not get the annotated method not > to get invoked at all. > Whether I call 'invocation.proceed()' or not, the method would still get > invoked and throw NullPointerException. > > I would love to make @XHR method to work, just not call the Ajax method if > any of the @Persist variables are null, > but still no luck. > > Any other ideas? > Thanks! > > On Sep 14, 2011, at 6:19 PM, Thiago H. de Paula Figueiredo wrote: > >> On Wed, 14 Sep 2011 16:25:14 -0300, Lenny Primak <[email protected]> >> wrote: >> >>> This is a design/best practices question. >>> We set up @Persist fields inside @SetupRender method. >>> When a session is invalid/expired and an Ajax event is called, >>> All these fields at null. >>> The question is if there is a better way to handle this situation than >>> having to check for Null in every Ajax event method for every @Persist >>> field? >> >> You don't need to check all of them, just whether Request.getSession(false) >> returns null or not. >> >>> I was thinking that @SetupRender should be called in case of session >>> expiration during Ajax call. >> >> I don't like this solution at all, as it uses a component event handler for >> doing something completely unrelated to rendering. You can even write class >> transformation to add some logic to be executed in AJAX requests when the >> session isn't valid. Taha wrote something similar (the @XHR annotation) in >> his Tapestry Magic blog: >> http://tawus.wordpress.com/2011/04/16/tapestry-magic-2-ajax-with-graceful-degradation/. >> >> On the other hand, I guess it's possible to implement a service that >> notifies listeners when the session is killed. I don't think it's possible >> to discern between timeout and normal session invalidation. >> >> -- >> Thiago H. de Paula Figueiredo >> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and >> instructor >> Owner, Ars Machina Tecnologia da Informação Ltda. >> http://www.arsmachina.com.br >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
