Total Pageviews

Friday, January 27, 2012

Getting URL Parameter Values

In straight way, our portlet does not have access to the URL parameter. The reason behind it is - requests are forwarded to portlets which are namespaced and portlets only have access to their namespaced parameters.

Things can be achived by hook or crook ;)

In a Controller class:
render() method
processAction() method
Hopefully will help you out someday. :)

Saturday, January 14, 2012

Knowing Liferay's URL Parameters

The sole reason for the evolution of DNS was making easy to remember URL, and it served its purpose very well. But sometimes we see a lot of things appended with that URL which is called Parameters. The URL and Parameters are separated by '?', multiple parameters are separated by '&' and parameters exists in key value pair distinguished by '='. 

The point that drags my attention is - if we can use Hidden parameters in request object and it serves purpose very well, then why it is needed to use Visible parameters? The answer is - when request is not directly coming back to page.

Following is the very general URL form of Liferay, lets understand it.


I hope no need to explain the part before '?'

This is the portlet ID of the portlet. This portlet ID is unique and that identifies portlet. It sometimes contains _INSTANCE_<some alphanumeric value> that tells that portlet instance can be made.

This parameter identifies the action of the portlet, means it identifies which method will be invoked - render() or processAction. 0 depicts render whereas 1 depicts processAction. Previously It was known as p_p_action in LR 5 and before. We have also seen struts_action parameter that tells the struts action path which was just served.

This parameter explains the window state of the portlet, which can be maximixed, minimized and exclusive.

Tells id of the page layout on which that instance of portlet is added.

Tells the column number in which the portlet is added.

Tells the total number of portlets in the current layout (page).

These values are handled by FriendlyURLMapper class which includes only those parameters which have some values, others are removed form the URL.