Yes, that was exactly my problem. I worked around it by obtaining the info I needed for the cookie from another source, but that too was ugly. Thanks for your help. I'll look into InvokeEngineTerminator, as you suggested, to try a better solution.
Denis -----Original Message----- From: Shawn Church [mailto:[EMAIL PROTECTED] Sent: quinta-feira, 6 de outubro de 2005 16:25 To: Tapestry users Subject: Re: Problem when using WebRequestServicerFilter I ran into exactly the same problem today, but my implementation did not involve cookie handling. Since the service call happens so early in the request, it appears RequestGlobals has not yet been instantiated. The exact error I get is: Property 'webRequest' of <OuterProxy for tapestry.globals.RequestGlobals(org.apache.tapestry.services.RequestGlobals) > is null. This exception was thrown on this code: if( _applicationStateManager != null ) visit = ( Visit ) _applicationStateManager.get("visit"); I was hoping this would be essentially a direct replacement for Engine.setupForRequest(), but this does not appear to be the case. I thought this would be the "correct" way to go about participating in the early request processing, but I am out of spare time to devote to messing with it. I ended up working around it by hooking into PageSource.getPage(), but this is pretty ugly. You might be able to implement your own WebRequestServicer. Take a look at org.apache.tapestry.services.impl.InvokeEngineTerminator. This is the default implementation for servicer.service(). In your case, your cookie logic won't work if it is performed after the servicer.service call unless you add the cookie headers to the existing response, since by that time the response has already been generated. Shawn Quoting Denis Souza <[EMAIL PROTECTED]>: > Hi, > > > > In a previous post I asked about handling persistent cookies in > Tapestry 4. > I finally got it to work the way I want it by using my own > implementation of > CookieSource (which is much like Tapestry's own implementation, > except for > the persistent cookie part) and the cookie logic is handled by a > class that > implements WebRequestServicerFilter and is configured in hivemind to > be be > called on every request. > > > > So I have my own implementation of WebRequestServicerFilter. In order > to > work correctly my "service" method must look something like this: > > > > public void service(WebRequest request, WebResponse response, > WebRequestServicer servicer) throws IOException { > > // Some of my logic here > > > > servicer.service(request, response); > > > > // More of my logic here > > } > > > > The "servicer.service(request, response)" call must be made so > Tapestry can > render the pages and do anything it needs to do. The problem seems to > be > that Tapestry's behavior differs in unexpected ways if I place my own > code > before or after the servicer.service() call. > > > > In this same class, I have injected an ApplicationStateManager object > so > that I can have access to the user's session. > > > > What happens is this: > > If I place any logic that accesses the session before the call to > servicer.service(), I get a null pointer exception somewhere in the > Tapestry > code. Anyway, since in the first request, at this point, the session > might > not have been created yet, it's understandable that it may not work > so I > guess I'd just have to place this logic after the call to > servicer.service(). > > > > This is where it gets strange: If I place cookie logic before the > call, > cookies work perfectly well, but if I place the cookie logic after > the call, > the cookies are not set in most of the requests! In this last case, > cookies > are only set sometimes in IE and never in Firefox. > > My problem is that my cookie logic requires that I access the > session. If I > place the logic before the call to "servicer.service()" I can't > access the > session. If I place it after the call, my cookies won't work. > > I have no idea why this is happening. I thought it might be a bug in > which > Tapestry does something to the request object after calling my > WebRequestServicerFilter class or some servlet api restriction that > I'm not > aware of that requires you to se the cookies early. > > > > Anyone know what could be happening? Any ideas for a workaround? I'm > using > Tapestry 4 beta 9 > > > > Thanks, > > Denis > > > > --------------------------------------------------------------------- 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]
