You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Akins <an...@gmail.com> on 2011/04/29 20:40:09 UTC
Problem with OGNL in FieldExpressionValidator
Can anyone help me understand how to use OGNL to capture session data in
this annotation?
I'm trying to use FieldExpressionValidator The Annotation has this
[expression = "!birthYearDisplayed || !birthYear.equals('')"]
birthYearDisplayed is on the session and set to true
When I execute the code, the annotation logs "WARN - Got result of null when
trying to get Boolean."
I also tried #session.birthYearDisplayed & #session['birthYearDisplayed']
Struts 2.2.1
--
Greg Akins
http://twitter.com/akinsgre
Re: Problem with OGNL in FieldExpressionValidator
Posted by Greg Akins <an...@gmail.com>.
Setting up a test app and trying to verify.
I suspect I'm doing something wrong elsewhere.
My test app has expression=("#session.isSet)
where session.put("isSet", true) is called in the index.action
And everything seems to work as expected.
I probably just needed a good night's sleep.. Thanks for listening.
--
Greg Akins
http://twitter.com/akinsgre
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with OGNL in FieldExpressionValidator
Posted by Dave Newton <da...@gmail.com>.
On Fri, Apr 29, 2011 at 9:01 PM, Greg Akins <an...@gmail.com> wrote:
> In this case, the session has the right value when the setter is
> executed, but the OGNL expression #session.birthYearEnabled is null
> (or seem to be null)
Just as a sanity check, birthYearEnabled (above) and
birthYearDisplayed (original posting) are different things; are you
looking for the right variable?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with OGNL in FieldExpressionValidator
Posted by Greg Akins <an...@gmail.com>.
On Fri, Apr 29, 2011 at 7:23 PM, Okan Özeren <ok...@gmail.com> wrote:
>
> Hi,
>
> I didn't read all of these, but maybe there are some usefull tips in this article:
> http://www.opensymphony.com/xwork/wikidocs/ExpressionValidator%20Tips.html
Not quite. Thanks though.
That article is mostly about the ExpressionValidator; I guess I need
more OGNL help.
I've always had a hard time understanding OGNL, so I'm sure I'm
making a mistake there.
In this case, the session has the right value when the setter is
executed, but the OGNL expression #session.birthYearEnabled is null
(or seem to be null)
I've tested this by executing the action.execute() and by calling the
annotations from a JUnit Test.
--
Greg Akins
http://twitter.com/akinsgre
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with OGNL in FieldExpressionValidator
Posted by Okan Özeren <ok...@gmail.com>.
Hi,
I didn't read all of these, but maybe there are some usefull tips in this
article:
http://www.opensymphony.com/xwork/wikidocs/ExpressionValidator%20Tips.html
Okan Özeren.
On Fri, Apr 29, 2011 at 9:40 PM, Greg Akins <an...@gmail.com> wrote:
> Can anyone help me understand how to use OGNL to capture session data in
> this annotation?
>
> I'm trying to use FieldExpressionValidator The Annotation has this
> [expression = "!birthYearDisplayed || !birthYear.equals('')"]
>
> birthYearDisplayed is on the session and set to true
>
> When I execute the code, the annotation logs "WARN - Got result of null
> when
> trying to get Boolean."
>
> I also tried #session.birthYearDisplayed & #session['birthYearDisplayed']
>
> Struts 2.2.1
> --
> Greg Akins
> http://twitter.com/akinsgre
>