Fórumok

get portlet title in JSP

Johannes Wagener, módosítva 15 év-val korábban

get portlet title in JSP

New Member Bejegyzések: 3 Csatlakozás dátuma: 2007.04.29. Legújabb bejegyzések
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.
thumbnail
Santh Chetan Chadalavada, módosítva 15 év-val korábban

Re: [Liferay Forums][3. Development] get portlet title in JSP

Junior Member Bejegyzések: 52 Csatlakozás dátuma: 2008.05.16. Legújabb bejegyzések
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, módosítva 15 év-val korábban

RE: get portlet title in JSP

New Member Bejegyzések: 3 Csatlakozás dátuma: 2007.04.29. Legújabb bejegyzések
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.
thumbnail
Santh Chetan Chadalavada, módosítva 15 év-val korábban

Re: [Liferay Forums][3. Development] RE: get portlet title in JSP

Junior Member Bejegyzések: 52 Csatlakozás dátuma: 2008.05.16. Legújabb bejegyzések
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, módosítva 14 év-val korábban

RE: get portlet title in JSP

New Member Bejegyzések: 6 Csatlakozás dátuma: 2009.08.17. Legújabb bejegyzések
I have the same problem!
Mitja Masten, módosítva 14 év-val korábban

RE: get portlet title in JSP

New Member Bejegyzések: 6 Csatlakozás dátuma: 2009.08.17. Legújabb bejegyzések
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 rodriguez, módosítva 11 év-val korábban

RE: get portlet title in JSP

New Member Bejegyzés: 1 Csatlakozás dátuma: 2012.03.21. Legújabb bejegyzések
Hi, i had the same problem, anyone looking on how to solve this, try this in the jsp:

&lt;%
String portletId = themeDisplay.getPortletDisplay().getId();
javax.portlet.PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(themeDisplay.getLayout(), portletId);
String portletCustomTitle = themeDisplay.getPortletDisplay().getTitle();
portletCustomTitle = portletSetup.getValue("portlet-setup-title-" + themeDisplay.getLanguageId(),portletCustomTitle);
%&gt;



it gives you the custom title the portlet has, then you just use it where you like
&lt;%=portletCustomTitle%&gt;