设置视图页面的标题名称

设置视图页面的标题名称

本文介绍了Liferay:设置视图页面的标题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个portlet,我想在其中设置标题作为不同页面的加载.我发现的解决方案是使用PortalUtil.addPageTitle (String myTitle, HttpServletRequest request),如此处.但是我不知道在这里以及如何使用它.任何的想法?只要不是javascript方法,任何其他选择都可以使用.

I have a portlet in which i want to set title as the different page loads. The solution i found is using PortalUtil.addPageTitle (String myTitle, HttpServletRequest request) as mentioned here. But i don't know here and how to use it. Any idea? Any alternative will also work as long as it is not javascript approach.

推荐答案

PortalUtil.addPageTitle (String myTitle, HttpServletRequest request)

设置页面标题(htmlTitle).不是portlet的标题.

sets the title of the page (htmlTitle). not the title of the portlet.

有两种解决方法,

Liferay提供了一个通过Portlet首选项设置标题的选项.

Liferay provides an option to set the title via portlet preferences.

PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, instanceId);
    Locale locale = new Locale("en", "US"); //straight to the point
    portletSetup.setValue("portlet-setup-title-" + LocaleUtil.toLanguageId(locale), title);
    portletSetup.setValue("portlet-setup-use-custom-title", "true");
    portletSetup.store();

在portlet类中,将标题设置为响应.

In your portlet class, you set the title to the response.

response.setTitle("Dynamic Title");

如果要更改页面标题,可以用两种不同的方式进行设置.您可以使用控制面板在每页上添加唯一的标题

If you want to change the title of the page, you can set that in two different ways. you can add unique title per page using the control panel

另一种方法是通过编程(下面是伪代码).

the other method is through programming (Below is the psuedocode).

layout.setHtmlTitle("dynamic Title");
layoutLocalserviceUtil.updateLayout(layout);

这篇关于Liferay:设置视图页面的标题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 02:42