Tuesday, October 4, 2016

Developing a MVCPortlet with Multiple Actions in Liferay

Today we will discuss how to develop a MVCPortlet with multiple action methods in Liferay. Here we create a portlet that contain two action methods with simple message.So lets start this step by step:-


Step 1:-Create Liferay Plugin Project 
Click on File  -->New -->Liferay plugin project. A screen will appear



Provide the Project name and Select Plugin Type as Portlet and click finish.

Step 2:-Create Portlet in Project
In package explorer Right click on project --> New --> Liferay Portlet


provide class name, package and select SuperClass as MVCPortlet.



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

view.jsp

Explanation:-
Here we simply create two actionURLs and two forms. Each actionURL is associated with a form.




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

Demo.java

Explanation:-
Here we create two method each method handle one form. The name of the methods must be same in the name variable in actionURL creation. Ex:-
<portlet:actionURL var="firstActionURL"  name="firstMethod" />
so first form is handle by firstMethod.





Step 5:-Check the Output
Deploy the portlet and add this to a page :-
On the Console:-
First=>Aditya First

On the Console:-
Second=>Second Test


Hope this will Help....

You can Download Source code from  Multiple Action Method in MVCPortlet. 

Related Post:-

No comments:

Post a Comment

Total Pageviews

Like Us on Facebook

Number Of Unique Visitor

Free counters!