You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paolo Beccari <pb...@email.it> on 2007/06/06 15:29:42 UTC
[S2] OGNL newbie: obtaining subset of a collection
Hi there,
here:
http://struts.apache.org/2.x/docs/ognl.html
I found that:
To select a subset of a collection (called projection), use a wildcard
within the collection.
? - All elements matching the selection logic
^ - Only the first element matching the selection logic
$ - Only the last element matching the selection logic
To obtain a subset of just male relatives from the object person:
person.relatives.{? #this.gender == 'male'}
I can't find the correct syntax to pass a variable (picked from valueStack)
instead of the string 'male'
Someone can help or point me the docs?
P.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] OGNL newbie: obtaining subset of a collection
Posted by Paolo Beccari <pb...@email.it>.
Laurie Harper wrote:
> L.
>
> ObWhine: please don't post unrelated questions to an existing thread. Be
> sure to start a new thread (with an appropriate subject) by sending a
> fresh message to the list, rather than using Reply To.
>
>
Thanks for the reply.
I'm sorry for the wrong posting, it was not what I intended to do.
P.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] OGNL newbie: obtaining subset of a collection
Posted by Laurie Harper <la...@holoweb.net>.
Paolo Beccari wrote:
>
> Hi there,
>
> here:
> http://struts.apache.org/2.x/docs/ognl.html
>
> I found that:
> To select a subset of a collection (called projection), use a wildcard
> within the collection.
> ? - All elements matching the selection logic
> ^ - Only the first element matching the selection logic
> $ - Only the last element matching the selection logic
> To obtain a subset of just male relatives from the object person:
> person.relatives.{? #this.gender == 'male'}
>
> I can't find the correct syntax to pass a variable (picked from valueStack)
> instead of the string 'male'
>
> Someone can help or point me the docs?
> P.
If the value you want to retrieve in place of the string 'male' is a
property on your action, just reference it by name. Otherwise, use the
'#' notation to access it, as in
person.relatives.{? #this.gender == someProperty}
person.relatives.{? #this.gender == #somethingElse}
If that doesn't do the trick, you'll need to post more details of what
data you have stored where and what you want to access.
L.
ObWhine: please don't post unrelated questions to an existing thread. Be
sure to start a new thread (with an appropriate subject) by sending a
fresh message to the list, rather than using Reply To.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org