Here are the steps to access services and util class of custom portlet in velocity template.
1) Make sure the services and util class which you want to access are available inside tomcat/lib/ext.
2) In order to access services you need to place below property inside portal-ext.
By default this property will be like this
Which means you wont be able to access serviceLocator inside velocity template.
So make sure before you access any service inside velocity template change this
3) Access services using findService Method of Custom Portlet in Velocity.
1) Make sure the services and util class which you want to access are available inside tomcat/lib/ext.
2) In order to access services you need to place below property inside portal-ext.
By default this property will be like this
Which means you wont be able to access serviceLocator inside velocity template.
So make sure before you access any service inside velocity template change this
3) Access services using findService Method of Custom Portlet in Velocity.
Normally we use findService(serviceName) method to access Liferay service.
But to access custom portlet service we have to use findService(contextName,ServiceName).
findService(serviceName) will search at the portal level and findService(servletContextName , serviceName) will search at specified portlet level.
But to access custom portlet service we have to use findService(contextName,ServiceName).
findService(serviceName) will search at the portal level and findService(servletContextName , serviceName) will search at specified portlet level.
4) Access Liferay Services using findService Method in Velocity
5) Access util class using findUtil Method for inbuilt Util of Liferay
http://www.liferay.com/web/raymond.auge/blog/-/blogs/2245146
Nice Blog..
ReplyDeletegood article.. thanks for sharing.. :) About Java
ReplyDeleteIn Liferay Portal 6.2, we enable accessing services in portal-ext.properties using this line of code:
ReplyDeletevelocity.engine.restricted.variables=
I spent several hours to recognize this change.
Hello all, i want to call a java method in a velocity code, i found your post about service Locator but i don't understand how to adapt my code in order to call my methode. Could you please help me!
DeleteThank you in advance.
Hi Amit,
DeleteI have tried the access the java class of a portlet from theme as followed by the above step, but still i can't access anything from the java class of portlet. But the above example is working fine with hook, not working with portlet only. Can u please tell me about the problem behind that.
This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
ReplyDeletebest rpa training in bangalore
rpa training in bangalore
rpa course in bangalore
RPA training in bangalore
rpa training in chennai
rpa online training
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeleteAWS Training in pune
AWS Online Training
AWS Training in Bangalore
Thank you so much for the great and very beneficial stuff that you have shared with the world.
ReplyDeleteUpgrade your career Learn Mulesoft Training in Bangalore from industry experts get Complete hands-on Training, Interview preparation, and Job Assistance at Softgen Infotech.
Really very happy to say, your post is very interesting to read. I never stop myself to say something about it. You’re doing a great job. Keep it up…
ReplyDeleteBecame an Expert In Cloud Computing Security Training! Learn from experienced Trainers and get the knowledge to crack a coding interview, @Softgen Infotech Located in BTM Layout.
I'd love to thank you for the efforts you've made in composing this post. I hope the same best work out of you later on too. I wished to thank you with this particular sites! Thank you for sharing. Fantastic sites!
ReplyDeletesap training in chennai
sap training in tambaram
azure training in chennai
azure training in tambaram
cyber security course in chennai
cyber security course in tambaram
ethical hacking course in chennai
ethical hacking course in tambaram
Wow i amazed with your blog,
ReplyDeleteThanks to share with us,
hadoop training in chennai
hadoop training in porur
salesforce training in chennai
salesforce training in porur
c and c plus plus course in chennai
c and c plus plus course in porur
machine learning training in chennai
machine learning training in porur
Really Nice Information It's Very Helpful All courses Checkout Here.
ReplyDeleteMicrosoft Dynamics CRM Training in Bangalore