Reputation: 33
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 ?
Upvotes: 0
Views: 1937
Reputation: 11698
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 :-)
Upvotes: 2