Monday, September 24, 2012

Plugin portlet Custom JSON Services

Plugin portlet Custom JSON Services:
1) Create Service.xml for you required Entity.
2) Run ant build-service
3) Run build-wsdd
4) Write required method in EntityServiceImpl.
5) Please check this method signature will created in EntityServiceUtil
6) Call the following URL to Access the custom method and this will return JSON array or JSON object.

Note: this is your host Name
JSONTest-portlet this is context path of your portlet.

The Following is Example:
Plugin Portlet Name: JSONTest-portlet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "">
<service-builder package-path="com.meera.test">

<entity name="Song" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="songId" type="long" primary="true" />
<!-- Audit fields -->
<column name="songName" type="String" />
<column name="songDesc" type="String" />

Method Name: getSongObject(long songId)

package com.meera.test.service.impl;
public class SongServiceImpl extends SongServiceBaseImpl {
public Song getSongObject(long songId) throws SystemException{
return SongUtil.fetchByPrimaryKey(songId);


Note: above method auto generate method after run service builder.
Write this Java script in view.jsp
<script src="/html/js/jquery/jquery.js" language="javascript"type="text/javascript"></script>

function getjsonParentObject(){
url :[songId]&songId=2',
dataType : "json",
success:function(msg) {
error : function() {


Location: Hyderabad, Andhra Pradesh, India


Post a Comment

Recent Posts

Recent Posts Widget

Popular Posts