Mustapha Aoussar
Mustapha Aoussar

Reputation: 5923

How to convert this line from Velocity to FreeMarker?

I want to convert this line from Velocity to Freemarker:

#set ($valid_portlet_description = $validator.isNotNull($portlet_description) 
&& $portlet_description.indexOf('javax.portlet.description') == -1)

I tried to change the code to:

<#assign valid_portlet_description = validator.isNotNull(portlet_description) 
&& portlet_description?index_of("javax.portlet.description") == "-1" />

But I get this following error:

freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates. Left hand operand is a freemarker.template.SimpleNumber Right hand operand is a freemarker.template.SimpleScalar

Upvotes: 0

Views: 802

Answers (1)

Tagir Valeev
Tagir Valeev

Reputation: 100209

The message complains about this statement:

portlet_description?index_of("javax.portlet.description") == "-1"

It says that you have different types: the number on the left, but SimpleScalar (which is just String in Freemarker terms) on the right. To fix this you should just remove quotes:

portlet_description?index_of("javax.portlet.description") == -1

Upvotes: 1

Related Questions