Pat,
OK, how do I override the application servlet (Jetty)?  Is this available from 
within Tapestry?

thanks,

Mark


-----Original Message-----
From: Patrick Casey [mailto:[EMAIL PROTECTED]
Sent: Tue 9/27/2005 11:22 AM
To: 'Tapestry users'
Subject: RE: Better way to statically get ahold of the visit object?
 

        Override application servlet and do this:

        private static final ThreadLocal fCurrentSession = new
ThreadLocal();

                protected void doService(HttpServletRequest request,
                        HttpServletResponse response) throws IOException,
ServletException {
                Clock c = new Clock();
                HttpSession s = request.getSession();
                fCurrentSession.set(s);
                synchronized (s) {
                        super.doService(request, response);
                }
                String temp = "Total Render time = " + c;
        }

        public static HttpSession getCurrentSession() {
                if (fCurrentSession == null)
                        return null;
                return (HttpSession) fCurrentSession.get();
        }

> -----Original Message-----
> From: Mark Stang [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 27, 2005 9:57 AM
> To: Tapestry users; Tapestry users
> Subject: RE: Better way to statically get ahold of the visit object?
> 
> Where are you getting the session?  Are you using 4.x?
> 
> regards,
> 
> Mark
> 
> 
> -----Original Message-----
> From: Muralidhar Y. [mailto:[EMAIL PROTECTED]
> Sent: Mon 9/26/2005 9:57 PM
> To: 'Tapestry users'
> Subject: RE: Better way to statically get ahold of the visit object?
> 
> Sorry a small correction :-
> 
> Public class Visit{
> 
>     // constructor.
>     public Visit(){
>         HttpSession s = (HttpSession) fCurrentSession.get();
>         s.setAttribute("visit", this) ;
>                  }
>    // other methods and code goes here.
> }//end of the Visit class.
> 
> 
>     public static Visit getVisit() {
>         HttpSession s = (HttpSession) fCurrentSession.get();
>         Object visit=s.getAttribute("visit");
>         return (Visit) e.getVisit();
>     }
> 
> 
> Muralidhar Y
> Software Engineer,
> Adastrum technologies-Nikai groups,
> EmiratesGroup-I.T Division,
> Dubai, UAE.
> Mobile : 00971-50-2256149.
> http://www.adastrumtech.com
> http://www.mercator.aero
> (Keep Smiling. Be happy All The Time.)
> 
> -----Original Message-----
> From: Muralidhar Y. [mailto:[EMAIL PROTECTED]
> Sent: 27 September 2005 07:35
> To: 'Tapestry users'
> Subject: RE: Better way to statically get ahold of the visit object?
> 
> Look at the following code. It might give you idea and better way of
> doing.
> 
> Public class Visit{
> 
>     // constructor.
>     public Visit(){
>         HttpSession s = (HttpSession) fCurrentSession.get();
>         s.setAttribute("visit", this) ;
>                  }
>    // other methods and code goes here.
> }//end of the Visit class.
> 
> 
>     public static Visit getVisit() {
>         HttpSession s = (HttpSession) fCurrentSession.get();
>         s.getAttribute("visit");
>         if(s != null)
>            return (Visit) e.getVisit();
>         return null;
>     }
> 
> 
> 
> 
> Muralidhar Y
> Software Engineer,
> Adastrum technologies-Nikai groups,
> EmiratesGroup-I.T Division,
> Dubai, UAE.
> Mobile : 00971-50-2256149.
> http://www.adastrumtech.com
> http://www.mercator.aero
> (Keep Smiling. Be happy All The Time.)
> 
> -----Original Message-----
> From: Patrick Casey [mailto:[EMAIL PROTECTED]
> Sent: 27 September 2005 00:33
> To: 'Tapestry users'
> Subject: Better way to statically get ahold of the visit object?
> 
> 
> 
>             Is there a better way to get ahold of the visit object
> statically (e.g. without access to the cycle or page objects?). Right now
> I'm using:
> 
> 
> 
> public static Visit getVisit() {
> 
>                         HttpSession s = (HttpSession)
> fCurrentSession.get();
> 
>                         Enumeration en = s.getAttributeNames();
> 
>                         while (en.hasMoreElements()) {
> 
>                                     String attrib = (String)
> en.nextElement();
> 
>                                     Log.info(attrib);
> 
>                                     if (attrib.startsWith(ENGINE_PREFIX))
> {
> 
>                                                 AbstractEngine e =
> (AbstractEngine) s.getAttribute(attrib);
> 
>                                                 return (Visit)
> e.getVisit();
> 
>                                     }
> 
>                         }
> 
>                         return null;
> 
>             }
> 
> 
> 
>             Which is sort of messy because it requires iterating every
> attribute in the session and doing string compares to find the right one.
> Is
> there a better approach (or one that doesn't involve doing an end run
> around
> the Tapestry Engine)?
> 
> 
> 
>             --- Pat
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to