I am having liferay portlet and I need to heavily depend upon the AJAX calls. So I need to make multiple calls to serveResource method. One way to do the same is that I can pass a parameter with the URL and then differentiate the request according to that parameter.
But in my case I have to call serveResource so many times due to which the method will be difficult to maintain. Is there any framework to do so? Using which the code becomes maintainable.
Use Spring MVC framework and call different method based on your business logic/user action in controller,
Try below code in jsp
ajax call in jsp
in controller/ java class
hope above code snippets will help you and you get what you were looking for!!!
Adding more in this.We can not use the
serveResource
method likeprocessAction
.There can be multiple processAction in single liferay portlet(Which is not spring mvc portlet) ,while in case ofserveReource
it will be single.serveResource
is mainly used for ajax call.We can handle multiple ajax request inserveResource
method by differentiating the call using resource Id.resourceRequest.getResourceID()
will return the Id, which we have defined in jsp using below code.