gpt4 book ai didi

java - Liferay:设置 View 页面的标题名称

转载 作者:行者123 更新时间:2023-11-30 04:33:11 26 4
gpt4 key购买 nike

我有一个 portlet,我想在其中设置不同页面加载时的标题。我找到的解决方案是使用 PortalUtil.addPageTitle (String myTitle, HttpServletRequest request) 如前所述 here 。但我不知道这里以及如何使用它。任何想法?只要不是 JavaScript 方法,任何替代方法都可以工作。

最佳答案

PortalUtil.addPageTitle (String myTitle, HttpServletRequest request)

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

有两种方法可以解决这个问题,

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

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 类中,您将标题设置为响应。

response.setTitle("Dynamic Title");

如果您想更改页面标题,可以通过两种不同的方式进行设置。您可以使用控制面板为每页添加唯一的标题

add title

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

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

关于java - Liferay:设置 View 页面的标题名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14133663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com