You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2005/09/26 22:32:54 UTC

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