Wednesday, October 5, 2016

Developing a MVCPortlet with Multiple Render Methods in Liferay

In the previous blog Developing a MVCPortlet with Multiple Actions in Liferay  we see how we can handle multiple action methods in a single portlet. Today we will discuss how to develop a MVCPortlet with multiple render methods in Liferay. Here we create a portlet that contain 4 render methods that will redirect to different jsps that contain simple messages.So lets start this step by step:-

Step 1:-Create Liferay Project and Portlet 
Create a Liferay plugin project and than create a portlet in it. You can check snapshot in my previous blog Developing a MVCPortlet with Multiple Actions in Liferay.

Step 2:-Change view.jsp
Open view.jsp and paste this content:-


Here we simply 4 URLs 2 renderURLs that use param mvcPath that will redirect to corresponding jsps. And 2 actionURLs that go to controller where we redirect to different jsps.

Step 3:-Change the Controller
Open your java class and paste this:-

Here we create a  method customRenderMethod that check the value of parameter nameofjsp and then set the parameter mvcPath.

Step 4:-Check the Output
Deploy the portlet and add this to a page :-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!