I've spent the last few hours to get a Struts expression to work as I want but didn' t succeeded.
I want to execute a OGNL expression from a String.
By example, I have the following code :
<s:push value="#row">
alert('<s:property value="id + ' ' + id" />');
</s:push>
This works perfectly giving me the id of the object twice.
This example
<s:push value="#row">
<s:set name="expr" value="id + ' ' + id"/>
alert('<s:property value="%{#expr}" />');
</s:push>
works fine too.
But now, if I create a method in my action :
public String getTest() {
return "id + ' ' + id";
}
and in the JSP :
<s:set name="expr" value="getTest()"/>
<s:push value="#row">
alert('<s:property value="%{#expr}" />');
</s:push>
The result is :
alert('id + ' ' + id');
which doesn't work because of quotes.
But why in my last example I have the String value and not the expression evaluated ?
I've tried a lot of possibilities, read articles, tutorials but didn't find a suitable answer to my problem.