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
Acess My DB service in FTl
I have added a db Bookmark and can acess it through service builder. How can I acess my service from ftl
import ServiceBuilder.model.Bookmarks;
import ServiceBuilder.service.BookmarksLocalService
In Ftl I'm Trying like this but no results
${serviceLocator.findService("Bookmarks", "ServiceBuilder.service.BookmarksLocalService")}
Hi Daniya, you might need to remove serviceLocator
from
the Restricted Variables configuration in System Settings >
FreeMarker Engine.
I would recommend that you create a template context contributor to inject either a "helper" class or your service to the templates instead of enabling service locator.
https://help.liferay.com/hc/en-us/articles/360018170931-Template-Context-Contributor
Using a "helper class" (usually I call it SomethingManager) has several advantages. You can fetch data from multiple services and combine them. You also can enrich the data from the service with extra information or prepare it for easier use in the frontend. This allows you to write rather clean freemarker code without a lot of logic.
It is also better from a security point of view to avoid enabling service locator. In the last years the use of Service Locator was restricted more and more (which is a good thing, IMHO, but of course, it forces you to settle your technical debt in that regard and convert everything to context contributors)
Powered by Liferay™