Dashboard > WebWork > ... > FAQ > Why won't the 'if' tag evaluate a one char string
  WebWork Log In View a printable version of the current page.  
  Why won't the 'if' tag evaluate a one char string
Added by Onyeje Bose, last edited by Chad Skeeters on Oct 02, 2006  (view change)
Labels: 
(None)

<ww:if test="myObj.myString == 'A'">
Why doesn't this work when myString is equal to A?
</ww:if>

OGNL will interpret 'A' as a char type and not a string. Simple solution - flip the double and single quotes.

<ww:if test='myObj.myString == "A"'>
This works!
</ww:if>

Alternatively, you can escape the double quotes in the String:

<ww:if test="myObj.myString == \"A\"">
This works!
</ww:if>

Old Syntax

<ww:if test="#myObj.myString == 'A'">
Why doesn't this work when myString is equal to A?
</ww:if>

OGNL will interpret 'A' as a char type and not a string. Simple solution - flip the double and single quotes.

<ww:if test='#myObj.myString == "A"'>
This works!
</ww:if>

Alternatively, you can escape the double quotes in the String:

<ww:if test="#myObj.myString == \"A\"">
This works!
</ww:if>

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators