Tuesday, October 18, 2016

Explanation in LiferayURL

Today we will discuss detail explanation of portlet URLs in Liferay. Here we create a portlet and on jsp we create a actionURL and a renderURL and than check the URL . So lets start this step by step:-

Step 1:-Create Liferay Project and Portlet 
Just create a project and then create a portlet in it. My project name is urltesting-portlet and portlet name is url-demo

Step 2:-Change view.jsp
Now open view.jsp and paste this:-


Here i create a actionURL that will hit firstMethod in the Controller. I also create renderURL will go to display.jsp.

Step 3:-Change the Controller
Now open your java file and paste this:-


Step 4:-Check ActionURL
Deploy your portlet and add to page.Here my page name is welcome and layout of page is 1 Column.Now i fill the value and click on submit Button.

Now check the browser URL:-

http://localhost:8080/web/guest/welcome?p_auth=Pa1eFFwX& p_p_id=urldemo_WAR_urltestingportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1 &p_p_col_count=1 &_urldemo_WAR_urltestingportlet _javax.portlet.action=firstMethod

Let me explain this URL:-

1)http://localhost:8080 :- Protocol+Host Address +Port

2)/web :- Because i added the portlet on Public page if it is private page then it become /group .

3)/guest :- Guest Community(Liferay Community).

4)/welcome :- Page name is welcome.

5)p_auth :- Authorization token generated by Liferay for Security.

6)p_p_id :- You can read more about portlet Id here.

7)p_p_lifecycle :- This is lifecycle of portlet .

  • 0: render phase or render URL
  • 1: action phase or action URL
  • 2: server resource URL

8)p_p_state :- Window State of Portlet.

9)p_p_mode :- portlet mode either view/edit/help

10)p_p_col_id :- Id of the column where our portlet is placed.

11)p_p_col_count :- Number of column in current layout.

12)p_p_id_javax.portlet.action :- portletid with action parameter.

Note:- If the portlet is instanceable then URL is:-

http://localhost:8080/web/guest/welcome?p_auth=Pa1eFFwX& p_p_id=urldemo_WAR_urltestingportlet_INSTANCE_TFuo5RrOTrfg&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1& _urldemo_WAR_urltestingportlet_INSTANCE_ TFuo5RrOTrfg_javax.portlet.action=firstMethod

Here only one parameter is extra ie instance id.

Step 5:-Check RenderURL
Now click on Render URL link:-

Now Check the URL:-

http://localhost:8080/web/guest/welcome?p_p_id= urldemo_WAR_urltestingportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_urldemo_WAR_urltestingportlet_mvcPath=%2Fhtml%2Furldemo%2Fdisplay.jsp

Note:- If the portlet is instanceable then URL is:-

http://localhost:8080/web/guest/welcome?p_p_id= urldemo_WAR_urltestingportlet_INSTANCE_TFuo5RrOTrfg&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=2 &_urldemo_ WAR_ urltestingportlet_INSTANCE_TFuo5RrOTrfg_mvcPath=%2Fhtml%2Furldemo%2Fdisplay.jsp

Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Like Us on Facebook

Number Of Unique Visitor

Free counters!