Mrakomor wrote:
Hello folks,
I wanted to use a Struts 2 select in the form. I wanted to populate the list
using filtered collection. If I use it without the filter, like this:
<s:select
name="depzad.dzRequest.contractList[%{#status.index}].selectedContract"
listKey="contractNr" listValue="contractNr"
list="depzad.dzZadostMat.contractList" />
it works just fine. In depzad.dzZadostMat.contractList is a list of the
contracts and contract numbers are in the select.
If I use a filter, that compares a number, it works too:
<s:select
name="depzad.dzRequest.contractList[%{#status.index}].selectedContract"
listKey="contractNr" listValue="contractNr"
list="depzad.dzZadostMat.contractList.{? #this.integerProperty>20}" />
"integerProperty" - there is a valid getter for the integerProperty in the
Contract class and the list I obtain is properly filtered.
However if the property for the filtering is a String:
<s:select
name="depzad.dzRequest.contractList[%{#status.index}].selectedContract"
listKey="contractNr" listValue="contractNr"
list="depzad.dzZadostMat.contractList.{? #this.stringProperty=='B'}" />
OGNL treats single chars in single quotes as chars, not strings.
http://struts.apache.org/2.x/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org