Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Dracus X
Problem displaying the correct page title
August 9, 2011 6:05 AM

Dracus X

Rank: New Member

Posts: 3

Join Date: March 3, 2010

Recent Posts


We have a problem displaying the correct page title of our pages in the web browser. Our portal runs in a Liferay 5.1.2 cluster (two nodes) of tomcat + apache http server.

The theme displays the page title according to two possible values:

1) Static page titles are configured with the Liferay’s "Manage Pages" portlet.
2) Some of our custom portlets create are dynamic page title using the PortalUtil.setPageTitle() method.

The problem is that the static page title isn't displayed correctly in pages that don't use any of our custom portlets. Instead, it displays a random page title that was created by a portlet before.

For example, suppose we have 2 pages:

/home -> no portlets -> static page title "home!"
/portlet -> our portlet -> sets dynamic page title "portlet!"

Then the /home shows "portlet!" too! We have debugged our code and the portlet code isn't executing, when we request the homepage.

We've looked at Liferay's source code and it seems that the dynamic title is stored in a request attribute, which is passed to the velocity template as "pageTitle". How could that attribute "survive" from older requests? The velocity template seems OK:

#set ($the_title = "")

#if ($layout.getHTMLTitle($locale))
#set ($the_title = $layout.getHTMLTitle($locale))
#if ($pageTitle)
#set ($the_title = $pageTitle)

It seems that Liferay caches the page title somewhere or that there is a problem with the cluster.

Any clue about what could be happening?

Thank you,
Dracus X.
Maros Strmensky
RE: Problem displaying the correct page title
July 19, 2012 4:29 AM

Maros Strmensky

Rank: New Member

Posts: 1

Join Date: July 19, 2012

Recent Posts

I had similar problem in Liferay 5.1.2 but it is not related to Cluster. It's just bug in Liferay.
In there is piece of code causing problems

 2if (_innerVelocityContext == null) {
 3    velocityContext = new VelocityContext();
 5    _innerVelocityContext = velocityContext;
 7else {
 8    velocityContext = new VelocityContext(_innerVelocityContext);

It is OK, but when it is started for the first time, velocityContext and _innerVelocityContext are the same. And if in this time you will call your portlet which will change title, or anything in Velocity attributes, then it will remain in the application until you will restart Liferay (because _innerVelocityContext is static). In other cases velocityContext is created with innerVelocityContext, but later all data are written into velocityContext and not into innerVelocityContext.

Sorry, I don't have any ideas how to fix this, I just have found out that this is a problem, and I'm trying to solve it somehow. Seems that it was changed in Liferay 6.0.6 then maybe this will not be a problem now.
Hitoshi Ozawa
RE: Problem displaying the correct page title
July 19, 2012 5:12 AM

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I've been using Liferay 6 and haven't seen the problem. May be it's time to upgrade?