I'd look closer at your expression as it doesn't seem valid:
<param name="expression"><![CDATA[user.country == '-1']]></param>
If it's always returning true, that implies the expression inside the CDATA
section is always false.
First I'd put the ! operand inside the CDATA section and use string quotes as
if you're comparing strings in java (not sure the latter matters, but it's
possible)
<param name="expression"><[CDATA[!(user.country == "-1")]]></param>
And if that doesn't work go even further and using proper string quality
with an equals method call:
<param name="expression"><[CDATA[!("-1".equals(user.country))]]></param>
Raghuveer Rawat wrote:
Thanks Jeromy, Sorry, I did not provide enough detail.
Only Header Key value is numeric '-1' so first option can be ruled out for
me.
For rest of the values Key is ISO Code e.g. USA and Value is Country Name
e.g. 'United States'
Below expression is not working for me.
<param name="expression"><![CDATA[user.country ==
'-1']]></param>
This condition is returning true whether I select a value in list box or
not..
What can be other ways to check drop down values?
Thanks
On Feb 10, 2008 10:50 PM, Jeromy Evans <[EMAIL PROTECTED]>
wrote:
If your keys are just numbers, perhaps you could use the Int Validator
<field-validator type="int">
<param name="min">0</param>
<message key="required.country"></message>
</field-validator>
http://struts.apache.org/2.x/docs/int-validator.html
Otherwise I'd try some variations of the expression. It's operating on
the getUser().getCountry() property of your action so the expression
(user.country == '-1') must be valid for its type.
Raghuveer Rawat wrote:
Hi, I need help for mandatory field validation for s:select.
I am trying to do client side xml validation.
jsp code for country list:
<s:select name="user.country" headerKey="-1" headerValue="Select
Country"
list="countryList" listKey="code"
listValue="name" required="true" />
I tried with below validation code but it is not working.. Not sure what
will be other approach..
<field name="user.country">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[user.country ==
'-1']]></param>
<message key="required.country"></message>
</field-validator>
</field>
Thanks a lot...
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.21/1267 - Release Date:
8/02/2008 8:12 PM
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.20.2/1270 - Release Date: 10/02/2008 12:21 PM
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]