Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Johannes Wagener
get portlet title in JSP
February 11, 2009 8:34 AM
Answer

Johannes Wagener

Rank: New Member

Posts: 4

Join Date: April 29, 2007

Recent Posts

Hello
i'm trying to get the portlet title in the view jsp.
<liferay-theme:defineObjects />
<%= themeDisplay.getPortletDisplay().getTitle() %>
works so far. but when i change the portlet title and its saved in the portlet preferences as portlet-setup-title-en_US, i still get the old default title.
is there an easy way to get the correct title (= the same title that is delivered to the browser)?
thank you.
Santh Chetan Chadalavada
Re: [Liferay Forums][3. Development] get portlet title in JSP
February 11, 2009 8:40 AM
Answer

Santh Chetan Chadalavada

Rank: Junior Member

Posts: 52

Join Date: May 15, 2008

Recent Posts

Hi Johannes, can you share your code to store preferences?

Johannes Wagener from liferay.com wrote:
> Hello
> i'm trying to get the portlet title in the view jsp.
> <liferay-theme:defineObjects />
> <%= themeDisplay.getPortletDisplay().getTitle() %>
> works so far. but when i change the portlet title and its saved in the
> portlet preferences as portlet-setup-title-en_US, i still get the old
> default title.
> is there an easy way to get the correct title (= the same title that
> is delivered to the browser)?
> thank you.
> --
> Liferay Message Boards
> http://www.liferay.com/web/guest/community/forums/-/message_boards/message/2154949
> mb.239390.2154949@events.liferay.com
> http://www.liferay.com
Johannes Wagener
RE: get portlet title in JSP
February 11, 2009 8:46 AM
Answer

Johannes Wagener

Rank: New Member

Posts: 4

Join Date: April 29, 2007

Recent Posts

sorry, maybe a misunderstanding.
i dont store the title manually.
i changed the portlet title the usual liferay way, by clicking on the portlet title and changing the text.
Santh Chetan Chadalavada
Re: [Liferay Forums][3. Development] RE: get portlet title in JSP
February 11, 2009 9:41 AM
Answer

Santh Chetan Chadalavada

Rank: Junior Member

Posts: 52

Join Date: May 15, 2008

Recent Posts

Oh ok. Let me point you to this post
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1605103
even portlet.vm gets it from portletdisplay the way you did. Not sure
why the problem?

Johannes Wagener from liferay.com wrote:
> sorry, maybe a misunderstanding.
> i dont store the title manually.
> i changed the portlet title the usual liferay way, by clicking on the
> portlet title and changing the text.
> --
> Liferay Message Boards
> http://www.liferay.com/web/guest/community/forums/-/message_boards/message/2156907
> mb.239390.2156907@events.liferay.com
> http://www.liferay.com
Mitja Masten
RE: get portlet title in JSP
September 15, 2009 3:32 AM
Answer

Mitja Masten

Rank: New Member

Posts: 6

Join Date: August 16, 2009

Recent Posts

I have the same problem!
Mitja Masten
RE: get portlet title in JSP
September 15, 2009 5:10 AM
Answer

Mitja Masten

Rank: New Member

Posts: 6

Join Date: August 16, 2009

Recent Posts

Found the reason.

Portlet JSP page content, where you call <%= portletDisplay.getTitle() %> is executed first. And getTitle() function returns fixed portlet (not custom) title.

Then portal renders portlet content through portal/render_portlet.jsp and common/themes/portlet.jsp. And portlet.jsp reads custom title (PortletConfigurationUtil.getPortletTitle()) and changes portletDisplay title through setTitle() function.

That is the reason, why portlet.vm template return correct custom title!

I think this is some kind of a bug and should be fixed.
Eg. portalDisplay title should be changed in earlier stage.
juan meza
RE: get portlet title in JSP
January 17, 2013 10:44 AM
Answer

juan meza

Rank: New Member

Posts: 1

Join Date: March 21, 2012

Recent Posts

Hi, i had the same problem, anyone looking on how to solve this, try this in the jsp:

1<%
2String portletId = themeDisplay.getPortletDisplay().getId();
3javax.portlet.PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(themeDisplay.getLayout(), portletId);
4String portletCustomTitle = themeDisplay.getPortletDisplay().getTitle();
5portletCustomTitle = portletSetup.getValue("portlet-setup-title-" + themeDisplay.getLanguageId(),portletCustomTitle);
6%>



it gives you the custom title the portlet has, then you just use it where you like
1<%=portletCustomTitle%>