You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by stanlick <st...@gmail.com> on 2008/01/29 23:38:13 UTC
#request scope
I have a weird situation where I am losing a request parameter inside a loop!
I understand the scopes and have trouble understanding how a #request scoped
variable could be "masked" inside a loop! This outputs my value just fine:
<s:property value="#request.model.parentId" />
but once inside
<s:iterator value="notes">
it no longer contains a value!
Any clues? Aren't the loop vars scoped to page?
Scott
--
View this message in context: http://www.nabble.com/-request-scope-tp15171139p15171139.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Dave Newton <ne...@yahoo.com>.
--- WongTseng <wa...@gmail.com> wrote:
> in S2, inside iteration, the item object is push onto the VS, so just
> remove the pound key.
Accessing a request attribute, however, still requires the "#" because it's a
named value on the stack, not simply a pushed action or the current object of
an iterator.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by WongTseng <wa...@gmail.com>.
in S2, inside iteration, the item object is push onto the VS, so just
remove the pound key.
--
Best Regards
Wong Tseng
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Musachy Barroso <mu...@gmail.com>.
btw #parameters['model.parentId'] will return an array, not just one
value, so #parameters['model.parentId'][0] will give you the value you
are looking for.
musachy
On Jan 31, 2008 2:07 PM, Laurie Harper <la...@holoweb.net> wrote:
> Dave Newton wrote:
> > --- stanlick@gmail.com wrote:
> >> Yeah, that's what I thought too! I'm passing the parameter via:
> >>
> >> <s:url id="url" action="%{actionClass}_show">
> >> <s:param name="model.parentId" value="id"/>
> >> </s:url>
> >>
> >> and the tag <s:property value="#request.model.parentId" /> outputs the
> >> number to the top of the page just fine.
> >
> > Do you have a "model" property in your action?
> >
> >> In fact, if I use #parameters.model.parentId I get nothing.
> >
> > If I use a parameter named "foo", set to "bar", I can't dupe this issue.
> >
> > If I include a "." operator then I'd suspect breakage as OGNL will attempt to
> > call "getParentId()" on an object called "model". These are expressions, not
> > simple, unparsed strings.
>
> Yeah, the period seems likely to be the issue, though I'm not sure why
> the expression would work in one context but not another in the same
> page. I would suggest two experiments:
>
> 1, per Dave, try renaming the parameter to something w/out a period in it.
>
> 2, if that works then try playing with the OGNL expression; something
> like #parameters['model.parentId'] may work (haven't tried that tho').
>
> L.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Martin Gainty <mg...@hotmail.com>.
//assuming request parameter..
#parameters['model.parentId']
http://struts.apache.org/2.x/docs/ognl-basics.html
//if you dont know the scope try
#attr['foo']
which will ref request/session/application respectively..
M-
----- Original Message -----
From: "Dave Newton" <ne...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, January 31, 2008 2:22 PM
Subject: Re: #request scope
> --- Laurie Harper <la...@holoweb.net> wrote:
> > Dave Newton wrote:
> > > --- stanlick@gmail.com wrote:
> > >> Yeah, that's what I thought too! I'm passing the parameter via:
> > >>
> > >> <s:url id="url" action="%{actionClass}_show">
> > >> <s:param name="model.parentId" value="id"/>
> > >> </s:url>
> > >>
> > >> and the tag <s:property value="#request.model.parentId" /> outputs
the
> > >> number to the top of the page just fine.
> > >
> > > Do you have a "model" property in your action?
> > >
> > >> In fact, if I use #parameters.model.parentId I get nothing.
> > >
> > > If I use a parameter named "foo", set to "bar", I can't dupe this
issue.
> > >
> > > If I include a "." operator then I'd suspect breakage as OGNL will
> > attempt to
> > > call "getParentId()" on an object called "model". These are
expressions,
> > not
> > > simple, unparsed strings.
> >
> > Yeah, the period seems likely to be the issue, though I'm not sure why
> > the expression would work in one context but not another in the same
> > page. I would suggest two experiments:
>
> I'm still not convinced it does; there is no way (that I'm aware of) that
a
> request parameter would ever be available as a request attribute, so I
think
> something else is happening there in the code. Most likely something is
> putting a model into request scope.
>
> > 2, if that works then try playing with the OGNL expression; something
> > like #parameters['model.parentId'] may work (haven't tried that tho').
>
> Correct; using map-style (i.e, stopping expression evaluation) works as
> expected.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Dave Newton <ne...@yahoo.com>.
--- Laurie Harper <la...@holoweb.net> wrote:
> Dave Newton wrote:
> > --- stanlick@gmail.com wrote:
> >> Yeah, that's what I thought too! I'm passing the parameter via:
> >>
> >> <s:url id="url" action="%{actionClass}_show">
> >> <s:param name="model.parentId" value="id"/>
> >> </s:url>
> >>
> >> and the tag <s:property value="#request.model.parentId" /> outputs the
> >> number to the top of the page just fine.
> >
> > Do you have a "model" property in your action?
> >
> >> In fact, if I use #parameters.model.parentId I get nothing.
> >
> > If I use a parameter named "foo", set to "bar", I can't dupe this issue.
> >
> > If I include a "." operator then I'd suspect breakage as OGNL will
> attempt to
> > call "getParentId()" on an object called "model". These are expressions,
> not
> > simple, unparsed strings.
>
> Yeah, the period seems likely to be the issue, though I'm not sure why
> the expression would work in one context but not another in the same
> page. I would suggest two experiments:
I'm still not convinced it does; there is no way (that I'm aware of) that a
request parameter would ever be available as a request attribute, so I think
something else is happening there in the code. Most likely something is
putting a model into request scope.
> 2, if that works then try playing with the OGNL expression; something
> like #parameters['model.parentId'] may work (haven't tried that tho').
Correct; using map-style (i.e, stopping expression evaluation) works as
expected.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Laurie Harper <la...@holoweb.net>.
Dave Newton wrote:
> --- stanlick@gmail.com wrote:
>> Yeah, that's what I thought too! I'm passing the parameter via:
>>
>> <s:url id="url" action="%{actionClass}_show">
>> <s:param name="model.parentId" value="id"/>
>> </s:url>
>>
>> and the tag <s:property value="#request.model.parentId" /> outputs the
>> number to the top of the page just fine.
>
> Do you have a "model" property in your action?
>
>> In fact, if I use #parameters.model.parentId I get nothing.
>
> If I use a parameter named "foo", set to "bar", I can't dupe this issue.
>
> If I include a "." operator then I'd suspect breakage as OGNL will attempt to
> call "getParentId()" on an object called "model". These are expressions, not
> simple, unparsed strings.
Yeah, the period seems likely to be the issue, though I'm not sure why
the expression would work in one context but not another in the same
page. I would suggest two experiments:
1, per Dave, try renaming the parameter to something w/out a period in it.
2, if that works then try playing with the OGNL expression; something
like #parameters['model.parentId'] may work (haven't tried that tho').
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> Yeah, that's what I thought too! I'm passing the parameter via:
>
> <s:url id="url" action="%{actionClass}_show">
> <s:param name="model.parentId" value="id"/>
> </s:url>
>
> and the tag <s:property value="#request.model.parentId" /> outputs the
> number to the top of the page just fine.
Do you have a "model" property in your action?
> In fact, if I use #parameters.model.parentId I get nothing.
If I use a parameter named "foo", set to "bar", I can't dupe this issue.
If I include a "." operator then I'd suspect breakage as OGNL will attempt to
call "getParentId()" on an object called "model". These are expressions, not
simple, unparsed strings.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by st...@gmail.com.
Yeah, that's what I thought too! I'm passing the parameter via:
<s:url id="url" action="%{actionClass}_show">
<s:param name="model.parentId" value="id"/>
</s:url>
and the tag <s:property value="#request.model.parentId" /> outputs the
number to the top of the page just fine. In fact, if I use
#parameters.model.parentId I get nothing. The problem is that I don't get
anything from the tag once inside the iterator.
On Jan 30, 2008 3:11 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- stanlick@gmail.com wrote:
> > Parameters and it contains the value immediately before entering the
> > iterator, as I am printing it out. Seems goofy to have to set a var
> just
> > to use it in the loop two lines later.
>
> #request is attributes. #parameters is parameters.
>
> I can't dupe the issue with attributes.
>
> d.
>
> >
> > On Jan 29, 2008 5:10 PM, Dave Newton <ne...@yahoo.com> wrote:
> >
> > > --- stanlick <st...@gmail.com> wrote:
> > > > I have a weird situation where I am losing a request
> > > > parameter inside a loop!
> > > > [...]
> > > > <s:property value="#request.model.parentId" />
> > >
> > > Doesn't "#request" retrieve request *attributes*?
> > >
> > > Dave
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: #request scope
Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> Parameters and it contains the value immediately before entering the
> iterator, as I am printing it out. Seems goofy to have to set a var just
> to use it in the loop two lines later.
#request is attributes. #parameters is parameters.
I can't dupe the issue with attributes.
d.
>
> On Jan 29, 2008 5:10 PM, Dave Newton <ne...@yahoo.com> wrote:
>
> > --- stanlick <st...@gmail.com> wrote:
> > > I have a weird situation where I am losing a request
> > > parameter inside a loop!
> > > [...]
> > > <s:property value="#request.model.parentId" />
> >
> > Doesn't "#request" retrieve request *attributes*?
> >
> > Dave
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Scott
> stanlick@gmail.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: #request scope
Posted by st...@gmail.com.
Parameters and it contains the value immediately before entering the
iterator, as I am printing it out. Seems goofy to have to set a var just to
use it in the loop two lines later.
On Jan 29, 2008 5:10 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- stanlick <st...@gmail.com> wrote:
> > I have a weird situation where I am losing a request
> > parameter inside a loop!
> > [...]
> > <s:property value="#request.model.parentId" />
>
> Doesn't "#request" retrieve request *attributes*?
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: #request scope
Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick <st...@gmail.com> wrote:
> I have a weird situation where I am losing a request
> parameter inside a loop!
> [...]
> <s:property value="#request.model.parentId" />
Doesn't "#request" retrieve request *attributes*?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org