简体   繁体   中英

Unable to call portlet resource url from javascript in liferay6.2

I am using Liferay Portal 6.2 CE GA3 I need to call my custom portlet resource method from another portlet jsp file. Below is my code.

 <a href ="#" onclick="myfunction('sometext')">Click here </a> <script> function myfunction(myVar){ AUI().use('aui-base','aui-io-request','liferay-portlet-url','aui-node',function(A){ var url = Liferay.PortletURL.createResourceURL(); url.setPortletId("MyCustomPortletId"); url.setResourceId('saveUserData'); A.io.request(url); }); } 

and my custom portlet ...

 public class MyCustomPortlet extends MVCPortlet{ public void saveUserData(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { System.out.println("in save UserData"); } render method---- } 

Here serveResource method (in my case saveUserData ) is not getting called. Any suggestions ?

Did you try calling your method from your own custom portlet just to be sure your saveUserData method is being called and has no issues?

Please try and then read forward if it does not work ;-)

serveResource method is always named as serveResource and not by any other name as saveUserData when you use Liferay's MVCPortlet .

You cannot have multiple serveResource methods as you can have action methods.

So rename your method to serveResource() and it should work :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM