如何同时使用多个主题

发布于 2025-01-07 18:50:36 字数 363 浏览 6 评论 0原文

我正在寻找一种在一个 XPage 应用程序中使用多个主题的方法,每个主题在应用程序的不同部分中处于活动状态。例如,支持具有面向公众的网站(自定义主题)和具有 OneUI 主题的 CMS 的单个 .nsf 应用程序。

您可以在应用程序属性中的 XPage 属性选项卡上设置整个应用程序使用哪个主题。也可以使用以下代码更改用户会话的主题:

context.setSessionProperty("xsp.theme", <theme_id>)

但这两个选项都为当前 .nsf 中的所有页面设置主题,并且我正在寻找一种指定主题 X 的方法应用程序的一部分和第二部分的主题 Y。

这可能吗?

I'm looking for a way to use multiple themes in one XPages application, each theme active in a different section of the application. For instance to support an single .nsf application with both a public facing website (custom theme) and a CMS with a OneUI theme.

You can set which theme is used through the whole application on the XPage Properties tab in Application Properties. It's also possible to change the theme for a user's session with this code:

context.setSessionProperty("xsp.theme", <theme_id>)

But both options set the theme for all pages in the current .nsf, and I'm looking for a way to specify theme X for one part of the application and theme Y for a second part.

Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

指尖微凉心微凉 2025-01-14 18:50:36

在任何应使用备用主题的页面上,使用以下语法将该属性直接应用于视图根:

<xp:view>
<xp:this.properties>
<xp:parameter name="xsp.theme" value="alternateThemeName" />
</xp:this.properties>
</xp:view>

On any page that should use an alternate theme, use the following syntax to apply the property directly to the view root:

<xp:view>
<xp:this.properties>
<xp:parameter name="xsp.theme" value="alternateThemeName" />
</xp:this.properties>
</xp:view>
献世佛 2025-01-14 18:50:36

我尝试了以上所有方法,但没有一个对我有用。但我找到了一个解决方案:

将其粘贴到视图的 beforeRenderResponse 事件中:

context.setSessionProperty("xsp.theme", "yourAlternateThemeName")

有一个问题:一旦使用这种方式,您必须始终在每个页面上使用它,因为这会设置一个会话属性,只要您登录,该属性就会存储在。

I tried all of the above, but none of them worked for me. But I found a solution:

Paste this into the view's beforeRenderResponse event:

context.setSessionProperty("xsp.theme", "yourAlternateThemeName")

There is one issue: once you have used this way you have to use it always and on every page as this sets a session property which is stored as long as you are logged in.

安人多梦 2025-01-14 18:50:36

刚刚与同事托尼·麦古金交谈过。

您可以更改每页的主题。在 XPage 的所有属性下,选择 data-properties 并创建一个名称为“xsp.theme”、值为“yourThemeName”的新属性。

Just talked with colleague Tony Mcguckin.

You can change the theme per page. Under all properties of the XPage select data-properties and create a new property with name "xsp.theme" and value "yourThemeName".

南风起 2025-01-14 18:50:36

虽然我喜欢使用特定于页面的主题的想法,但根据您所描述的特定用例,“正确”的方法是将两个单独的 XPage 应用程序绑定到同一个后端数据存储。这不仅使得为每个应用程序指定不同的主题变得简单,还简化了 ACL(假设您将有不同的人访问公共站点与 CMS),通过为每个应用程序设置不同的设置,可以更轻松地调整性能,即使没有特定于应用程序的设置,也应该稍微提高性能,只是因为 Java 类加载器行为:每个 NSF 充当不同的 ClassLoader,并且 NSF 中的每个 XPage 或自定义控件都会导致存储单独的类文件。因此,理论上,如果您的公共站点的功能要求您创建 5 个 XPage,而 CMS 功能跨越 10 个 XPage,只需将它们拆分为两个单独的应用程序,就可以让类加载器更轻松地检索用户加载的任何页面的类,因为它不必忽略该用户永远不需要的类,只是为了找到当时确实需要的一个类。因此,我仍然想找到一种方法来让特定于页面的主题仅用于其“酷”因素,但为了这个特定目的,我建议完全使用两个不同的应用程序,并为每个应用程序分配不同的主题。

While I like the idea of having page-specific themes, based on the specific use case you're describing, the "right" way to do this is to have two separate XPage applications bound to the same back end data store. Not only does this make it simple to specify a different theme for each, it also simplifies the ACL (assuming you'll have different people accessing the public site vs. the CMS), makes it easier to tune performance by having different settings per application, and even without having application-specific settings, should improve performance slightly just because of Java class loader behavior: each NSF acts as a distinct ClassLoader, and each XPage or Custom Control in your NSF results in the storage of a separate class file. So, in theory, if the features of your public site require you to create 5 XPages and the CMS features span 10 XPages, simply splitting these into two separate apps makes it easier for the class loader to retrieve the class for any page a user loads, because it doesn't have to ignore the classes it will never need for that user just to find the one class it does need at the time. So I'm still tempted to find a way to get page-specific themes working just for the "cool" factor of it, but for this specific purpose, I'd recommend using two different applications entirely, with a different theme assigned to each.

骷髅 2025-01-14 18:50:36

我对主题不太了解,但是你不能检查你的主题(使用一些 ssjs)在哪个 viewroot (通过 id?),并根据它包括正确的样式,CSS 和其他资源吗?

I dont know that much about themes but cant you check in your theme (with some ssjs) at which viewroot ( by id? ) you are and according to that include the correct styles , css and other resources?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文