1

I have two variables set like this:

<s:set var="A" value="true" />
<s:set var="B" value="false" />

I want to generate the HTML below with a custom attribute info like this :

<td info="truefalse">&#160;</td>

I tried the following lines in my JSP file but I can't get true next to false:

<td info="<s:property value="#A?'true':'false'+#B?'true':'false'""/>&#160;</td>

outputs: <td info="true">&#160;</td>

<td info="<s:property value="#A" /><s:property value="#B" />">&#160;</td>

outputs: <td info="false">&#160;</td>

Stephan
  • 41,764
  • 65
  • 238
  • 329

3 Answers3

2

OGNL uses + to concatenate strings. Having boolean values to convert to string, you should do something like

<s:property value="%{''+#A+#B}"/> 
Roman C
  • 49,761
  • 33
  • 66
  • 176
1

Use <s:if> Try this

<s:set var="A" value="true" />
<s:set var="B" value="false" />

<td info="<s:if test="%{#A==true}">true</s:if><s:else>false</s:else><s:if test="%{#B==true}">true</s:if><s:else>false</s:else>">&#160;</td>
 OR
<td info="<s:property value="#A" /><s:property value="#B" />">&#160;</td>

outputs:

<td info="truefalse">&#160;</td>

Reason: You can not concatenate Boolean. You need to convert Boolean to string and you can concatenate strings only.

prem30488
  • 2,828
  • 2
  • 25
  • 57
0

Try this this might help you..

<td info="<s:property value="A"></s:property><s:property value="B"></s:property>">&#160;</td>