Total Pageviews

Monday, February 28, 2011

Calling remote service method using Javascript/JSON

Liferay enables us to call the methods using Javascript. There are various advantages of it, but the most useful is - we can call a method without refreshing a the portlet (without rendering), and we can display contents as per logic.

Step 1. Firstly, generate your service for your entity keeping remote-service="true"  in service.xml

Step 2. Write a method in ServiceImpl that you wish to call from Javascript.

Step 3. Build service using ant, from ext-impl.

Step 4. Deploy the whole project.

Step 5. Method will be available in ext-web/docroot/html/js/liferay/ext_service.js.

Step 6. Include js in the jsp file you need to call the method, as follows:

<script type="text/javascript" src="/html/js/liferay/ext_service.js"></script>
Step 7. Call method as follows in javascript:

This is it... All the best...


  1. Just wonder if you have any example of calling into a server method with Java object parameters rather than primitive type?

    E.g. your lifeIt() method on the server takes has this signature:

    likeIt(Token token, String postId)

    Where Token is just a user defined Java object?


  2. Can we access the same in custom portlet developed in plugins sdk(LR 5.2.x)

  3. I have read your blog its very attractive and impressive. I like it your blog.

    JavaEE Training in Chennai JavaEE Training in Chennai

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

  4. You made some good points there. I did a search on the topic and found most people will agree with your blog. Java Training in Chennai

  5. Somebody necessarily help to make severely posts I might state. This is the first time I frequented your website page and to this point? I surprised with the research you made to create this particular post extraordinary. Well done admin..
    PEGA Training in Chennai

  6. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!

    Java Training in Bangalore

  7. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.

    java training in bangalore


  8. Wow!! What a interesting blog.. Really awesome to read and so informative blog.. Keep ongoing such a great blog..
    Austere Technologies |Internet Of Things

  9. Great article, really very helpful content you made. Thank you, keep sharing.

    Application Quality Managment Services | Austere Technology Solutions

  10. Very good informative article. Thanks for sharing such nice article, keep on up dating such good articles.

    Best Mobility Services | Austere Technology Solutions

  11. Needed to compose one little word yet thanks much for the suggestions that you are contributed here, please do keep on sharing the new updates...
    Best Online Software Training Institute | HTMML JavaScript Training


  12. Thanks for sharing this informative article..!!
    Keep posting waiting for next post.

    Java Training in Bangalore
    iOS Training in Bangalore

  13. Really great blog, it's very helpful and has great knowledgeable information.

    Best Blockchain services | Massil Technologies

  14. It is really a great work and the way in which u r sharing the knowledge is excellent. Thanks for helping me to understand basic concepts. Thanks for your informative article. Java Training in Chennai | Pega Training in Chennai

  15. Your article gives lots of information to me. Thanks for sharing.
    acca course in hyderabad | ISFS