Yeah, I'm using Java 1.4.2 and I just couldn't get the injects in the
.page to inherit.
Following Derick's tip, I came up with this (if it helps anyone else),
which seems to work so far (although I'm not claiming it to be the best
way):
public abstract class Page extends BasePage implements
PageBeginRenderListener
{
private ApplicationStateManager stateManager = null;
public void pageBeginRender(PageEvent event)
{
if (stateManager == null)
stateManager =
event.getRequestCycle().getInfrastructure().getApplicationStateManager()
;
}
public Application getApplication()
{
return (Application) stateManager.get("application");
}
public Session getSession()
{
return (Session) stateManager.get("session");
}
public boolean getSessionExists()
{
return stateManager.exists("session");
}
}
Thanks for the tips!
/dev/mrg
PS. "application" = "global" and "session" = "visit" -- I renamed
everything to make sure I caught omissions/errors.
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Ron Piterman
Sent: Thursday, December 22, 2005 7:28 PM
To: [email protected]
Subject: Re: Abstract superclass for pages with injection in T4?
ok - it seems you don't use jdk1.5. the .page file does not get
inherited.
The only solution I can see is copy/paste the <inject to all your .page
defs.
Gentry, Michael (Contractor) wrote:
> Since getVisit() and getGlobal() have been deprecated and I need the
> visit on every page in my application and the global on some of them,
I
> decided to try to roll my own solution. I've searched through the
> documentation and this list, but still haven't stumbled across the
right
> magic. What I have is:
>
> AbstractPage (Tapestry)
> BasePage (Tapestry)
> CommonPage (Mine)
> Home/etc (Mine)
>
> In CommonPage.java I have:
>
> public abstract class CommonPage extends BasePage
> {
> public abstract Application getApplication(); // was getGlobal()
> public abstract Session getSession(); // was getVisit()
> }
>
> CommonPage.page contains:
>
> ...
> <inject property="session" type="state" object="session"/>
> ...
>
> Home extends CommonPage. I also have a hivemodule.xml file. When I
> load Home, the session is never injected and getSession returns null.
> If I move the <inject...> from CommonPage.page to Home.page, the
> injection will occur and I'll get a session. However, I don't want to
> have to have an <inject...> in every single .page (seems kind of
silly).
>
> Does anyone have suggestions for making this work? I could continue
> using getVisit() and getGlobal(), but I really don't want any warnings
> (even if they are just deprecation) present in my build. Also, I
never
> could stumble upon the correct <inject...> syntax for a global object.
>
> Thanks!
>
> /dev/mrg
>
> PS. T4 RC1 with Java 1.4.2.
>
> ---------------------------------------------------------------------
> 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]