Message Boards

Use RandomUtil in Freemarker template in theme

Sathish Kumar, modified 3 Years ago.

Use RandomUtil in Freemarker template in theme

New Member Posts: 3 Join Date: 5/27/16 Recent Posts
I need to use RandomUtil in my ftl to generate random numbers. I have set freemarker.engine.restricted.variables as empty in portal-ext.properties. Am unable to get reference to it . I have tried static util which returned class not found exception, while UtilLocator returned "no bean named ***RandomUtil" exception. Is there any other way to implement this?  
thumbnail
David H Nebinger, modified 3 Years ago.

RE: Use RandomUtil in Freemarker template in theme

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Actually, I'd suggest building a ContextContributor to inject an instance into the FM context using a name you can look for later on. That way you avoid having to figure out the lookups to use.