掲示板

Plugins SDK & JSON Remote Service

12年前 に Uli Jaan によって更新されました。

Plugins SDK & JSON Remote Service

New Member 投稿: 2 参加年月日: 11/09/18 最新の投稿
I simply want to develop a portlet with a JSON service using Liferay IDE (Eclips Helios) and the Liferay Plugins SDK. See source below. I run "build servies" in Liferay IDE (Build Successful). Calling a page containing the portlet returns a NullPointerException (via JavaScript alert from view.jsp). What is wrong here?

service.xml:

<!--?xml version="1.0"?-->

<service-builder package-path="de.company.liferay.portlet.test">
	<namespace>TestNamespace</namespace>
	<entity name="Test" local-service="true" remote-service="true" />
</service-builder>



view.jsp

<script src="/test-portlet/js/service.js" language="JavaScript"> </script>
<script src="http://localhost:8080/html/js/jquery/jquery.js" language="JavaScript"> </script>

<script language="javascript">

function invokeService() {
	
	Liferay.Service.TestNamespace.Test.test(
        {
            msg: "Invoking a Liferay service via JavaScript",
        },
        function(message) {
            var exception = message.exception;
            if (!exception) {
                alert("No Exception");
            }
            else {
            	alert(exception);
            }
        }
    );
}	

invokeService();

</script>	



TestServiceBaseImpl.java:


package de.company.liferay.portlet.test.service.impl;

public class TestServiceImpl extends TestServiceBaseImpl {

	public String test(String message) {

		System.out.println("### REMOTE SERVICE CALLED: " + message);
		
		return "success";
	}
}
thumbnail
12年前 に Apoorva Prakash によって更新されました。

RE: Plugins SDK & JSON Remote Service

Liferay Master 投稿: 658 参加年月日: 10/06/15 最新の投稿
Hi Uli Jaan,
Have a look on this link.
However, this is for LR-5.2.3, but most of things are common except the difference of plugin and ext approach.
In case, you get any issue again, you can ask.

Hope this will help...
Thanks and Regards...
12年前 に Uli Jaan によって更新されました。

RE: Plugins SDK & JSON Remote Service

New Member 投稿: 2 参加年月日: 11/09/18 最新の投稿
Hi Apoorva Prakash,

I already tried your example with the plugin approach (Eclipse IDE, Plugins SDK, Portlet Plugin Type). This causes me running in the errors described above. Would you mind implementing your example with the Plugin SDK an check whether you will run into the same errors?
thumbnail
12年前 に Apoorva Prakash によって更新されました。

RE: Plugins SDK & JSON Remote Service

Liferay Master 投稿: 658 参加年月日: 10/06/15 最新の投稿
Hi Uli Jaan,
Uli Jaan:

I already tried your example with the plugin approach (Eclipse IDE, Plugins SDK, Portlet Plugin Type). This causes me running in the errors described above.

My example is for LR-5.2.3 EXT environment. Usage of JS services was not available in plugin of the same version.
Uli Jaan:
Would you mind implementing your example with the Plugin SDK an check whether you will run into the same errors?

I've done JS thing in LR-6.x and it working cool. Just try it out in LR-6, and let me know if there is some issue.
Things remains same, you get the js file withing the WAR of the portlet.

Hope this will help.
Thanks and Regards.