In the previous blog we see how to to access Liferay Services in Velocity(VM) files using Service Locator. In this blog we will see how to to access Custom Services in Velocity(VM) files using Service Locator.
Create Service
First create services and deploy the services. Cut the jar file from lib folder and paste in ..\tomcat-7.0.42\lib\ext so that it is available to all other projects. I created a project employee-portlet which contain all the services . When i build the services employee-portlet-service.jar is created.
Note:- When you copy the jar from project lib to \tomcat-7.0.42\lib\ext make sure to delete the jar from project lib.
For Theme
If you want to access employee services in your theme you can use this code in portal_normal.vm:-
Explanation:-
Here findService() method take two arguments first is your context name(project name of your services) and second is full path of your service class.
For Web Content Templates
You can use the above code in your templates files but you need to do one extra step. Just enter :-
velocity.engine.restricted.variables=
in your portal-ext.properties and restart server.
Hope this will Help....
Related Post:-
How to access Liferay Services in VM files
Categorization in web content
Structure and Template in Web Content
Fetch Web Content Programmatically
Get Journal Article Using SAX Parser
Form Handling in Spring Portlet
Embedding a Web Content in a Portlet
Fetch Latest Version Journal Article or Web Content in Liferay
Related Post:-
How to access Liferay Services in VM files
Categorization in web content
Structure and Template in Web Content
Fetch Web Content Programmatically
Get Journal Article Using SAX Parser
Form Handling in Spring Portlet
Embedding a Web Content in a Portlet
Fetch Latest Version Journal Article or Web Content in Liferay
No comments:
Post a Comment