Reputation: 21
I have an Object
with a string vector as one of its attributes in the ftl. I have to use the if
condition and enter a specfic block only when the vector contains some dynamic variable(available in the ftl)
I have tried to use the condition like
<#if (aObject.bVector.contains(dVariable))>
But this gives an invalid reference exception.
bVector
is populated with data in java layer but i am not sure if this method can be used or not.
Upvotes: 2
Views: 474
Reputation: 351
You can use
<#if aObject.bVector?seq_contains('value')>
Note than freemarker cannot access members directly: You need to have public accessors.
The aObject class also needs to be marked as public.
Source: FreeMarker Manual
Edit: Make sure aObject.bVector is not null.
Upvotes: 2
Reputation: 1434
it should go like this <#if aObject.bVector?seq_contains(dVariable?string)></#if>
Upvotes: 1