Total Pageviews

Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

Thursday, February 9, 2012

Using Web Contents on our portlets's JSP page

Web contents is really a very great feature of Liferay which allows us to create any kind of valid HTML with the help of very good HTML editor and use it on Liferay pages. But the way Liferay provide to use these web contents on the page is using the web content display portlet.

Generally, text on the JSP pages is loaded form properties file. Now what I think if there is some big content, we can load that from web content. That will be very helpful in externalizing. Another advantage is we can load different contents using the same name for different groups. Let's see how is that possible -

Enter the name of the Article in portal-ex.properties-

Now use the following code on JSP-
Hope this will help. Cheers !!!

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 JSP:
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.


http://localhost:8080/web/guest/home?p_p_id=56_INSTANCE_5ViU&p_p_lifecycle=1&p_p_state=maximized&p_p_col_id=column-2&p_p_col_pos=2&p_p_col_count=4


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


p_p_id
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.

p_p_lifecycle
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.


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


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


p_p_col_pos
Tells the column number in which the portlet is added.


p_p_col_count
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.

Saturday, October 1, 2011

Available implicit objects Liferay JSP page

On a normal JSP page, some objects are implicitly available. In addition, we can get several others in Liferay using the taglibs. But we don't know all. So, lets become a technical James Bond and investigate about it. :D

Lets see about normal JSP first:
These objects are created by the container automatically and the container makes them available to us. Since these objects are created automatically by the container and are accessed using standard variables; and that is why, they are called implicit objects. They are parsed by the container. They are available only within the jspService method and not in any declaration.

These are 9 objects.
Now, lets ebter the liferay context:

The following statements  will give 14 default objects :
And the following statements will give 18 default objects :
and the type of each object as follows :
These default objects can be acquired using pageContext which is an implicit object of JSP. Use the following code for getting default objects.


So, here are the objects that I found. Hope this will help.