You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gabriel Belingueres <be...@gmail.com> on 2008/08/27 17:15:36 UTC
[S2] non intuitive OGNL value evaluation?
Hi,
Please see this lines:
<s:property value='#parameters.eventoId'/><br/>
<s:property value='%{"hello" + #parameters.eventoId}'/><br/>
<s:property value='%{"hello" + #parameters.eventoId[0]}'/>
Let's say that parameter eventoId == 9, it outputs:
9
hello[Ljava.lang.String;@144c5bb
hello9
The funny thing is that #parameters.eventoId' is evaluated to String
when it's alone (what I expected to be), but it is evaluated to an
String array when concatenated like in "hello" + #parameters.eventoId.
As expected, taking the first array element ([0]) solves the problem.
But the question is if this is OK to be this way, am I building the
OGNL expression wrongly, or is it some bug in the OGNL evaluation
code?
Gabriel
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] non intuitive OGNL value evaluation?
Posted by Gabriel Belingueres <be...@gmail.com>.
Positively sure.
Forgot to mention: I'm testing against S2.1.2
2008/8/27, Musachy Barroso <mu...@gmail.com>:
> Parameters are an array, so "parameters.eventoId" is an String
> array(hence "[Ljava.lang.String;@144c5bb"), to get the actual value
> you need to always do "parameters.eventoId[0]". Are you sure that it
> print "9" for the first one?
>
> musachy
>
> On Wed, Aug 27, 2008 at 11:15 AM, Gabriel Belingueres
> <be...@gmail.com> wrote:
> > Hi,
> >
> > Please see this lines:
> >
> > <s:property value='#parameters.eventoId'/><br/>
> > <s:property value='%{"hello" + #parameters.eventoId}'/><br/>
> > <s:property value='%{"hello" + #parameters.eventoId[0]}'/>
> >
> > Let's say that parameter eventoId == 9, it outputs:
> >
> > 9
> > hello[Ljava.lang.String;@144c5bb
> > hello9
> >
> > The funny thing is that #parameters.eventoId' is evaluated to String
> > when it's alone (what I expected to be), but it is evaluated to an
> > String array when concatenated like in "hello" + #parameters.eventoId.
> > As expected, taking the first array element ([0]) solves the problem.
> >
> > But the question is if this is OK to be this way, am I building the
> > OGNL expression wrongly, or is it some bug in the OGNL evaluation
> > code?
> >
> > Gabriel
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] non intuitive OGNL value evaluation?
Posted by Gabriel Belingueres <be...@gmail.com>.
I wonder if could be added a #param object to the ActionContext that
represent a parameter but returns a String (to avoid those evaluation
issues), after all, the programmer knows if he expect one or many
values in their request parameters and can use either #param or
#parameters as needed.
2008/8/27, Pierre Thibaudeau <pi...@gmail.com>:
> 2008/8/27 Dave Newton <ne...@yahoo.com>:
> > IIRC it will--OGNL plays some games to try and do what it thinks you want to;
>
> Microsoft products too try to do what they think you want...
> It's absolutely maddening!
> ;)
>
> ---------------------------------------------------------------------
> 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: [S2] non intuitive OGNL value evaluation?
Posted by Pierre Thibaudeau <pi...@gmail.com>.
2008/8/27 Dave Newton <ne...@yahoo.com>:
> IIRC it will--OGNL plays some games to try and do what it thinks you want to;
Microsoft products too try to do what they think you want...
It's absolutely maddening!
;)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] non intuitive OGNL value evaluation?
Posted by Dave Newton <ne...@yahoo.com>.
IIRC it will--OGNL plays some games to try and do what it thinks you want to; I'm not what all the rules are, though.
--- On Wed, 8/27/08, Musachy Barroso <mu...@gmail.com> wrote:
> From: Musachy Barroso <mu...@gmail.com>
> Subject: Re: [S2] non intuitive OGNL value evaluation?
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Wednesday, August 27, 2008, 11:31 AM
> Parameters are an array, so "parameters.eventoId"
> is an String
> array(hence "[Ljava.lang.String;@144c5bb"), to
> get the actual value
> you need to always do "parameters.eventoId[0]".
> Are you sure that it
> print "9" for the first one?
>
> musachy
>
> On Wed, Aug 27, 2008 at 11:15 AM, Gabriel Belingueres
> <be...@gmail.com> wrote:
> > Hi,
> >
> > Please see this lines:
> >
> > <s:property
> value='#parameters.eventoId'/><br/>
> > <s:property value='%{"hello" +
> #parameters.eventoId}'/><br/>
> > <s:property value='%{"hello" +
> #parameters.eventoId[0]}'/>
> >
> > Let's say that parameter eventoId == 9, it
> outputs:
> >
> > 9
> > hello[Ljava.lang.String;@144c5bb
> > hello9
> >
> > The funny thing is that #parameters.eventoId' is
> evaluated to String
> > when it's alone (what I expected to be), but it is
> evaluated to an
> > String array when concatenated like in
> "hello" + #parameters.eventoId.
> > As expected, taking the first array element ([0])
> solves the problem.
> >
> > But the question is if this is OK to be this way, am I
> building the
> > OGNL expression wrongly, or is it some bug in the OGNL
> evaluation
> > code?
> >
> > Gabriel
> >
> >
> ---------------------------------------------------------------------
> > 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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] non intuitive OGNL value evaluation?
Posted by Musachy Barroso <mu...@gmail.com>.
Parameters are an array, so "parameters.eventoId" is an String
array(hence "[Ljava.lang.String;@144c5bb"), to get the actual value
you need to always do "parameters.eventoId[0]". Are you sure that it
print "9" for the first one?
musachy
On Wed, Aug 27, 2008 at 11:15 AM, Gabriel Belingueres
<be...@gmail.com> wrote:
> Hi,
>
> Please see this lines:
>
> <s:property value='#parameters.eventoId'/><br/>
> <s:property value='%{"hello" + #parameters.eventoId}'/><br/>
> <s:property value='%{"hello" + #parameters.eventoId[0]}'/>
>
> Let's say that parameter eventoId == 9, it outputs:
>
> 9
> hello[Ljava.lang.String;@144c5bb
> hello9
>
> The funny thing is that #parameters.eventoId' is evaluated to String
> when it's alone (what I expected to be), but it is evaluated to an
> String array when concatenated like in "hello" + #parameters.eventoId.
> As expected, taking the first array element ([0]) solves the problem.
>
> But the question is if this is OK to be this way, am I building the
> OGNL expression wrongly, or is it some bug in the OGNL evaluation
> code?
>
> Gabriel
>
> ---------------------------------------------------------------------
> 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: [S2] non intuitive OGNL value evaluation?
Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 8/27/08, Gabriel Belingueres wrote:
> [...] or is it some bug in the OGNL evaluation code?
I wouldn't call it a "bug" per se, but instead "unexpected, designed behavior". In other words, I believe it's doing that on purpose.
There are some other situations in which OGNL will evaluate things differently based on the expression things are in.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org