Wednesday, June 28, 2017

Liferay Portlet URL in JavaScript

Today we will see how create Portlet URL in JavaScript. Some time we have a situation in which we don't want to submit a form but need to send the values of fields from view to controller. In this post we create a text box in which we fill the value and get this value in our controller without submitting any form.

So lets start this Step by Step:-

Step 1:-Create a Basic Portlet
Here i create a project with name fordemo-portlet and then create a portlet HelloWorld in it.

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

Here i create two scripts one for link and second for button.You can use any one based on your requirement.

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

Step 4:-Check the output
Deploy your portlet and add the portlet on page:-

Fill the value in text field and click on Link or Button .The value is printed in console.

Note:- URL created in both the cases is:-

http://localhost:8080/c/portal/layout?p_l_id=10678 &p_p_id = helloworld_WAR_fordemoportlet&p_p_lifecycle=0&_helloworld_WAR_fordemoportlet_userName=Aditya

You can download the source code from here.

Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!