tags:

views:

2468

answers:

1

i have an object called 'item'. it has a property called 'type'

when i do this:

<s:property value="item.type" />

i get this: Q

ok, so i can read the value, but when i try this:

<s:property value="item.type == 'Q'" />

i get an empty string

this give me an empty string:

<s:property value="%{#item.type == 'Q'}" />

i even tried this:

<s:property value="item.type.equals('Q')" />

but i got this string: false

how do i get 'true'?

+1  A: 

I don't think you can put any EL inside the value property of this tag. You could accomplish that with something like:

<s:if test="%{#item.type == 'Q'}">
  true
</s:if>
<s:else>
  false
</s:else>

More examples of this are here

Note - I use freemarker for the view, so the above may not be exact. In freemarker you could do this with an assign:

<#assign val = (item.type == 'Q')/>
${val}

Or, you could also use the if construct like above:

<#if (item.type == 'Q')>true<#else>false</#if>
Brian Yarger