Thanks Ben,
I am going to try, I find it a bit of hack. And I find strange that
there is no access to the registry.
Thanks
Numa
Le 9 févr. 07 à 20:24, Ben Dotte a écrit :
I'm not sure if there is a more straightforward way, but one way is
to store the servlet into the request and then pull out the
ServletContext from that.
So make a subclass of org.apache.tapestry.ApplicationServlet:
public class MyApplicationServlet extends ApplicationServlet
{
protected void doService(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException
{
request.setAttribute("servlet", this);
super.doService(request, response);
}
}
Set it up in web.xml:
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>path.to.MyApplicationServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Then pull out the registry in your base page:
public Registry getRegistry()
{
return (Registry) ((MyApplicationServlet) getRequestCycle
().getInfrastructure().getRequest().getAttribute
("servlet")).getServletContext().getAttribute
("org.apache.tapestry.Registry:app");
}
Ben
-----Original Message-----
From: Numa Schmeder [mailto:[EMAIL PROTECTED]
Sent: Friday, February 09, 2007 1:08 PM
To: Tapestry users
Subject: Re: Migration to Tap4, accessing the hivemind registry
without injection
I knew that, but I don't know how to access a context from a Page or
from the request cycle.
How can you get the servlet context?
Thanks,
Numa
Le 9 févr. 07 à 19:49, Shing Hing Man a écrit :
A singleton has the advantage of letting you access
the registry in non-web pages.
In case you did not know,
the registry is created in the ApplicationServlet and
stored as a context parameter.
// context is the servlet context
Registry registry = (Registry) context
.getAttribute(ApplicationServlet.REGISTRY_KEY_PREFIX_PUBLIC
+
"(the name of ApplicationServlet given in web.xml");
Shing
--- Numa Schmeder <[EMAIL PROTECTED]> wrote:
Nop, but isn't an easier way to just access the
registry?
Le 9 févr. 07 à 19:33, Shing Hing Man a écrit :
Have you considered implementing the HiveMind
registry
as a singleton ?
The zebra-hivemind subproject in Zebra does
exactly
that.
http://zebra.berlios.de/
Shing
--- Numa Schmeder <[EMAIL PROTECTED]> wrote:
Hello,
I am migrating an application from tap3 to tap4,
I
am hitting a lot
of problem.
One of those is getting a reference to the
hivemind
registry from
java without using injection.
I have a base page who used to provide a
DAOFactory
to all my
subclassing pages, now the DAOFactory is in the
hivemind registry.
I don't want to go to each page specification to
inject the DAO
Factory and I can't use annotations. So I would
like to access the
hivemind registry programmatically.
How can I do, I have checked many docs but
couldn't
find a clue.
Could someone help me please!
Thanks
Numa
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
All New Yahoo! Mail - Tired of unwanted email
come-ons? Let our
SpamGuard protect you.
http://uk.docs.yahoo.com/nowyoucan.html
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
--
This message has been 'sanitized'. This means
that potentially
dangerous content has been rewritten or removed.
The following
log describes which actions were taken.
Sanitizer (start="1171047249"):
Split unusually long Date: header.
SanitizeFile (filename="unnamed.txt",
mimetype="text/plain"):
Match (names="unnamed.txt", rule="2"):
Enforced policy: accept
Total modifications so far: 1
Anomy 0.0.0 : Sanitizer.pm
$Id: Sanitizer.pm,v 1.90 2005/01/04 20:30:13 bre
Exp $
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
Now you can scan emails quickly with a reading pane. Get the new
Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
This message has been 'sanitized'. This means that potentially
dangerous content has been rewritten or removed. The following
log describes which actions were taken.
Sanitizer (start="1171048257"):
Split unusually long Date: header.
SanitizeFile (filename="unnamed.txt", mimetype="text/plain"):
Match (names="unnamed.txt", rule="2"):
Enforced policy: accept
Total modifications so far: 1
Anomy 0.0.0 : Sanitizer.pm
$Id: Sanitizer.pm,v 1.90 2005/01/04 20:30:13 bre Exp $
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]