RE: accessing cayenne sessions

From: Cypher her (cypher6..otmail.com)
Date: Tue Apr 04 2006 - 18:36:53 EDT

  • Next message: Cypher !: "RE: accessing cayenne sessions"

    Hi

    I am using Tapestry 4, Java 1.5, JBoss 4 and Cayenne 1.2.

    So if I undrstand you correctly I can create a subclass of BasePage which
    will have a getSession() method. But in that page, to get the session I
    would need to use the WebApplicationContextFilter and do something like

    add his to my web.xml

    <filter>
        <filter-name>CayenneFilter</filter-name>
        
    <filter-class>org.objectstyle.cayenne.conf.WebApplicationContextFilter</filter-class>
    </filter>
    ...
    <filter-mapping>
        <filter-name>CayenneFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    and create a class like this

    import org.objectstyle.cayenne.access.DataContext;

    public class MyBasePage extends BasePage
    {

        public DataContext getDataContext()
        {
            return DataContext.getThreadDataContext();
        }
    }

    and all of my pages should subclass MyBasePage. And I am assuming Tapestry
    and the servlet container will take care of making sure the Session is
    consistent throughout the workflow i.e. each user gets a unique DataContext
    and they maintain the same DataContext from page to page until the session
    times out..

    Thanks again for your help.

    Lawrence

    From: "Gentry, Michael (Contractor)" <michael_gentr..anniemae.com>
    Reply-To: cayenne-use..ncubator.apache.org
    To: <cayenne-use..ncubator.apache.org>
    Subject: RE: accessing cayenne sessions
    Date: Tue, 4 Apr 2006 10:45:29 -0400

    Yes, but using Tapestry you can have a common superclass for your pages
    that provides a getSession() method and it works transparently. You
    don't need to think about Http*.

    /dev/mrg

    -----Original Message-----
    From: Mike Kienenberger [mailto:mkienen..mail.com]
    Sent: Tuesday, April 04, 2006 10:26 AM
    To: cayenne-use..ncubator.apache.org
    Subject: Re: accessing cayenne sessions

    On 4/4/06, Cyp her <cypher6..otmail.com> wrote:
    > * Are there any convenient methods for accessing the Session like in
    > WebObjects where there is a session class in the application?

    In servlets, there's an HttpSession object that you can pull out of
    the HttpServletRequest. Instead of being a subclassable object, it
    instead holds references to a Map (think NSDictionary) where you can
    store objects the entire session. How you get a reference to your
    HttpSession object depends on the framework.

    http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/Http
    Session.html

    _________________________________________________________________
    Be the first to hear what's new at MSN - sign up to our free newsletters!
    http://www.msn.co.uk/newsletters



    This archive was generated by hypermail 2.0.0 : Tue Apr 04 2006 - 18:37:19 EDT