Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Use RandomUtil in Freemarker template in theme
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?
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.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™