You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pratt <th...@gmail.com> on 2008/02/23 00:56:57 UTC

OGNL Insanity

I am seeing the most unexplainable results imaginable.  I have the
following line of OGNL:

 '<s:property value="%{#parameters.display}"/>' == 'dependent':
<s:property value="%{#parameters.display == 'dependent'}"/>

Which is outputting:

'dependent' == 'dependent': false

How is that even possible?  I am writing out the value of the display
request parameter and it's value is the string 'dependent'.  When I
use the very same struts tag to evaluate the expression, it returns
false?  What am I missing here?

  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: OGNL Insanity

Posted by Antonio Petrelli <an...@gmail.com>.
2008/2/23, Chris Pratt <th...@gmail.com>:
>   '<s:property value="%{#parameters.display}"/>' == 'dependent':
>  <s:property value="%{#parameters.display == 'dependent'}"/>

Uh, it seems like a Quine :-)

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OGNL Insanity

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> It's returning an array of Strings (since this is a parameter).  But
> if it's used one way it is treated as a single value, if it is used a
> slightly different way, it is treated as an array, 

Guess so, although I have to admit I'd probably never use a parameter
directly in a JSP like that.

Not sure how far along the non-OGNL EL efforts are at this point; you could
always take it up with the OGNL people, though.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OGNL Insanity

Posted by Chris Pratt <th...@gmail.com>.
It's returning an array of Strings (since this is a parameter).  But
if it's used one way it is treated as a single value, if it is used a
slightly different way, it is treated as an array, that is not
developer friendly.  In this case.  If it is used as:

'<s:property value="${#parameters.display}"/>'

The value returned is 'dependent' which would translate to either
request.getParameterValues("display")[0] or
request.getParameter("display")

If the code is changed very slightly to

<s:property value="${#parameters.display == 'dependent'}"/>

It is now treated as getParameterValues().equals("dependent")

In one case it is taking the fact that the length of the array is 1
and helping out the programmer.  In the other, very similar code, it
is not.

At the very, very least this code should be predictable, which this code is not.

Either the first code should return '[Ljava.lang.String@8176171' or
the second should perform getParameter().equals("dependent").  Either
would be acceptable.
  (*Chris*)

On Fri, Feb 22, 2008 at 4:40 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- Chris Pratt <th...@gmail.com> wrote:
>  > On Fri, Feb 22, 2008 at 4:10 PM, Dave Newton <ne...@yahoo.com> wrote:
>  > > --- Chris Pratt <th...@gmail.com> wrote:
>  > >  > I am seeing the most unexplainable results imaginable.  I have the
>  > >  > following line of OGNL:
>  > >  >
>  > >  >  '<s:property value="%{#parameters.display}"/>' == 'dependent':
>  > >  > <s:property value="%{#parameters.display == 'dependent'}"/>
>  > >  >
>  > >  > Which is outputting:
>  > >  >
>  > >  > 'dependent' == 'dependent': false
>  > >  >
>  > >  > How is that even possible?  I am writing out the value of the display
>  > >  > request parameter and it's value is the string 'dependent'.  When I
>  > >  > use the very same struts tag to evaluate the expression, it returns
>  > >  > false?  What am I missing here?
>  > >
>  > >  <s:property value="#parameters.display.class"/>
>  > >
>  >
>  > Dave, thanks for the cryptic reply, it pointed me in the right
>  > direction.  I wasn't crazy about OGNL before and it's stuff like this
>  > that makes me like it even less.
>
>  Hmm... I haven't dug very deep, but if this is an OGNL "issue" I'd guess it's
>  happening somewhat earlier in the process; I'm guessing it's just returning
>  whatever it's finding in the map. Just a guess, though.
>
>
>
>  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: OGNL Insanity

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> On Fri, Feb 22, 2008 at 4:10 PM, Dave Newton <ne...@yahoo.com> wrote:
> > --- Chris Pratt <th...@gmail.com> wrote:
> >  > I am seeing the most unexplainable results imaginable.  I have the
> >  > following line of OGNL:
> >  >
> >  >  '<s:property value="%{#parameters.display}"/>' == 'dependent':
> >  > <s:property value="%{#parameters.display == 'dependent'}"/>
> >  >
> >  > Which is outputting:
> >  >
> >  > 'dependent' == 'dependent': false
> >  >
> >  > How is that even possible?  I am writing out the value of the display
> >  > request parameter and it's value is the string 'dependent'.  When I
> >  > use the very same struts tag to evaluate the expression, it returns
> >  > false?  What am I missing here?
> >
> >  <s:property value="#parameters.display.class"/>
> >
> 
> Dave, thanks for the cryptic reply, it pointed me in the right
> direction.  I wasn't crazy about OGNL before and it's stuff like this
> that makes me like it even less.

Hmm... I haven't dug very deep, but if this is an OGNL "issue" I'd guess it's
happening somewhat earlier in the process; I'm guessing it's just returning
whatever it's finding in the map. Just a guess, though.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OGNL Insanity

Posted by Chris Pratt <th...@gmail.com>.
On Fri, Feb 22, 2008 at 4:10 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- Chris Pratt <th...@gmail.com> wrote:
>  > I am seeing the most unexplainable results imaginable.  I have the
>  > following line of OGNL:
>  >
>  >  '<s:property value="%{#parameters.display}"/>' == 'dependent':
>  > <s:property value="%{#parameters.display == 'dependent'}"/>
>  >
>  > Which is outputting:
>  >
>  > 'dependent' == 'dependent': false
>  >
>  > How is that even possible?  I am writing out the value of the display
>  > request parameter and it's value is the string 'dependent'.  When I
>  > use the very same struts tag to evaluate the expression, it returns
>  > false?  What am I missing here?
>
>  <s:property value="#parameters.display.class"/>
>

Dave, thanks for the cryptic reply, it pointed me in the right
direction.  I wasn't crazy about OGNL before and it's stuff like this
that makes me like it even less.

The whole point of an EL is to be usable by everyone from simple HTML
coders all the way up to mighty Java folks.  I thought we stopped
requiring Java coding in the HTML long ago.

But now OGNL is bringing it right back.  In order to use OGNL you have
to understan not only the datastructures used to hold data used on the
server side (String vs String[] vs Map vs List), but you also have to
remember where everything is.

The old JSP EL might have been simplistic, but that was one of it's
greatest benefits, you could guess with ~100% accuracy what any
statement was going to do.

Sorry to vent, but the more I use OGNL the more frustrated I get.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OGNL Insanity

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> I am seeing the most unexplainable results imaginable.  I have the
> following line of OGNL:
> 
>  '<s:property value="%{#parameters.display}"/>' == 'dependent':
> <s:property value="%{#parameters.display == 'dependent'}"/>
> 
> Which is outputting:
> 
> 'dependent' == 'dependent': false
> 
> How is that even possible?  I am writing out the value of the display
> request parameter and it's value is the string 'dependent'.  When I
> use the very same struts tag to evaluate the expression, it returns
> false?  What am I missing here?

<s:property value="#parameters.display.class"/>

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org