You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Chiappone <ch...@gmail.com> on 2007/05/16 22:11:00 UTC
Injecting RequestGlobals
I have been forced to downgrade my application that I've started to
java 1.4 for the time being and am trying to inject a hivemind service
but don't seem to be doing it right because the object I am trying to
get injected seems to be null
In my component spec i have the following:
<inject property="requestGlobals"
object="service:tapestry.globals.HttpServletRequest"
type="org.apache.tapestry.services.RequestGlobals"/>
and in my java class i have:
private RequestGlobals requestGlobals;
public RequestGlobals getRequestGlobals() {
return requestGlobals;
}
public void setRequestGlobals(RequestGlobals requestGlobals) {
this.requestGlobals = requestGlobals;
}
Thanks,
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Injecting RequestGlobals
Posted by Chris Chiappone <ch...@gmail.com>.
Ok I'm pulling my hair out here. This used to work fine in java 5 and
annotations but since having to go back to page specs I can't seem to
pass parameters to components.
This worked fine before
java:
@Parameter
public abstract String getInclude();
html:
<span jwcid="@JspInclude" include="/header.jsp"/>
Now I have changed the code to this
java:
public abstract String getInclude();
public abstract void setInclude(String include);
jspInclude.jwc:
<component-specification class="com.test.components.JspInclude"
allow-informal-parameters="yes"
allow-body="yes">
<parameter name="include" required="yes"/>
...
Unfortunately include always is null. What seems to be wrong here?
On 5/16/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> That's probably because HttpServletRequest is a type of
> javax.servlet.http.HttpServletRequest and not RequestGlobals.
>
> I would change your inject tag to look more like:
>
> <inject property="request" object="service:
> tapestry.globals.HttpServetRequest" />
>
> public abstract HttpServletRequest getRequest();
>
> Starting with tapestry >= 4.1 you can also just skip the <inject> tag
> altogether as most services can be autowired.
>
> On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
> >
> > Oh and I've also tried making the getters and setters abstract and
> > that didn't work either.
> >
> > On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
> > > I have been forced to downgrade my application that I've started to
> > > java 1.4 for the time being and am trying to inject a hivemind service
> > > but don't seem to be doing it right because the object I am trying to
> > > get injected seems to be null
> > >
> > > In my component spec i have the following:
> > >
> > > <inject property="requestGlobals"
> > > object="service:tapestry.globals.HttpServletRequest"
> > > type="org.apache.tapestry.services.RequestGlobals"/>
> > >
> > > and in my java class i have:
> > >
> > > private RequestGlobals requestGlobals;
> > >
> > >
> > > public RequestGlobals getRequestGlobals() {
> > > return requestGlobals;
> > > }
> > >
> > >
> > > public void setRequestGlobals(RequestGlobals requestGlobals) {
> > > this.requestGlobals = requestGlobals;
> > > }
> > >
> > >
> > > Thanks,
> > >
> > > --
> > > ~chris
> > >
> >
> >
> > --
> > ~chris
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Injecting RequestGlobals
Posted by Jesse Kuhnert <jk...@gmail.com>.
That's probably because HttpServletRequest is a type of
javax.servlet.http.HttpServletRequest and not RequestGlobals.
I would change your inject tag to look more like:
<inject property="request" object="service:
tapestry.globals.HttpServetRequest" />
public abstract HttpServletRequest getRequest();
Starting with tapestry >= 4.1 you can also just skip the <inject> tag
altogether as most services can be autowired.
On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
>
> Oh and I've also tried making the getters and setters abstract and
> that didn't work either.
>
> On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
> > I have been forced to downgrade my application that I've started to
> > java 1.4 for the time being and am trying to inject a hivemind service
> > but don't seem to be doing it right because the object I am trying to
> > get injected seems to be null
> >
> > In my component spec i have the following:
> >
> > <inject property="requestGlobals"
> > object="service:tapestry.globals.HttpServletRequest"
> > type="org.apache.tapestry.services.RequestGlobals"/>
> >
> > and in my java class i have:
> >
> > private RequestGlobals requestGlobals;
> >
> >
> > public RequestGlobals getRequestGlobals() {
> > return requestGlobals;
> > }
> >
> >
> > public void setRequestGlobals(RequestGlobals requestGlobals) {
> > this.requestGlobals = requestGlobals;
> > }
> >
> >
> > Thanks,
> >
> > --
> > ~chris
> >
>
>
> --
> ~chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Jesse Kuhnert
Tapestry/Dojo team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
RE: Injecting RequestGlobals
Posted by Ben Dotte <bd...@widen.com>.
Hi Chris,
I believe you can just do this:
<inject property="requestGlobals"
object="service:tapestry.globals.RequestGlobals" />
public abstract RequestGlobals getRequestGlobals();
We've been on annotations exclusively for a while so hopefully my memory
is right about that..
Ben
-----Original Message-----
From: Chris Chiappone [mailto:chiappone@gmail.com]
Sent: Wednesday, May 16, 2007 3:15 PM
To: Tapestry List
Subject: Re: Injecting RequestGlobals
Oh and I've also tried making the getters and setters abstract and
that didn't work either.
On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
> I have been forced to downgrade my application that I've started to
> java 1.4 for the time being and am trying to inject a hivemind service
> but don't seem to be doing it right because the object I am trying to
> get injected seems to be null
>
> In my component spec i have the following:
>
> <inject property="requestGlobals"
> object="service:tapestry.globals.HttpServletRequest"
> type="org.apache.tapestry.services.RequestGlobals"/>
>
> and in my java class i have:
>
> private RequestGlobals requestGlobals;
>
>
> public RequestGlobals getRequestGlobals() {
> return requestGlobals;
> }
>
>
> public void setRequestGlobals(RequestGlobals requestGlobals) {
> this.requestGlobals = requestGlobals;
> }
>
>
> Thanks,
>
> --
> ~chris
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Injecting RequestGlobals
Posted by Chris Chiappone <ch...@gmail.com>.
Oh and I've also tried making the getters and setters abstract and
that didn't work either.
On 5/16/07, Chris Chiappone <ch...@gmail.com> wrote:
> I have been forced to downgrade my application that I've started to
> java 1.4 for the time being and am trying to inject a hivemind service
> but don't seem to be doing it right because the object I am trying to
> get injected seems to be null
>
> In my component spec i have the following:
>
> <inject property="requestGlobals"
> object="service:tapestry.globals.HttpServletRequest"
> type="org.apache.tapestry.services.RequestGlobals"/>
>
> and in my java class i have:
>
> private RequestGlobals requestGlobals;
>
>
> public RequestGlobals getRequestGlobals() {
> return requestGlobals;
> }
>
>
> public void setRequestGlobals(RequestGlobals requestGlobals) {
> this.requestGlobals = requestGlobals;
> }
>
>
> Thanks,
>
> --
> ~chris
>
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org