On 5/25/07, Janko Muzykant <[EMAIL PROTECTED]> wrote:
i couldn't find a proper answers to the following questions so i would be grateful if someone could enlighten me a bit. * how to get a current page that component is rendered on? I know there is almost no difference between pages and components in T5. in such a case, how to get a 'root' component that acts as a Page in T4?
Must of this involves access to the ComponentResources for your component. ComponentResources is a window into the structure Tapestry builds around your classes. @Inject private ComponentResources _resources; The page component is available as _resources.getPage(). You can cast from Component down to the actual class. * how to get current HttpSession? I know how to get a Session object but it
is not enough as it doesn't have an 'invalidate' method for example.
There's a JIRA issue about adding additional methods to Session. You can inject the RequestGlobals service, and obtain HttpServletRequest from it, then the session from the request. * the same thing with HttpServletRequest. There is a Request but it doesn't
allow to get/set attributes. * how to get a ServletContext object?
You can work through the RequestGlobals. If you use these a lot, you can use the ShadowBuilder service to create services that shadow properties of RequestGlobals, much as the Request service: public Request buildRequest() { return _shadowBuilder.build(_requestGlobals, "request", Request.class); } Once a shadow service exists, you can inject that service directly. I guess these question may look a bit silly but unfortunately they are a
real stoppers in my migration to T5. umrzyk.
-- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com