如何在不重启服务器的情况下动态更新 JSF2.0 (Primefaces) 工具提示 [英] How to update the JSF2.0 (Primefaces) tooltips dynamically without server restart

查看:26
本文介绍了如何在不重启服务器的情况下动态更新 JSF2.0 (Primefaces) 工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不重启服务器的情况下动态更新 JSF2.0 (Primefaces) 工具提示.

I need to update the JSF2.0 (Primefaces) tooltips dynamically without server restart.

意思是需要找到一种方法,可以在不需要重启服务器的情况下更改正在运行的应用程序的工具提示(来自属性文件的 atm).

Meaning need to find a way where tooltips (atm from properties file) of the a running application can be changed without requiring a server restart.

我们正在运行 websphere 并部署一个非爆炸的 EAR(可能会说服部署爆炸的战争)

We are running websphere and deploying a non exploded EAR (can probably convince to deploy exploded war)

请提供任何想法或提示.谢谢你

Any Ideas or tips please. Thanks you

推荐答案

p:toolTip 组件的 value 属性必须是 EL 表达式或文字文本.通常,人们会在工具提示的 EL 表达式中引用使用 f:loadBundle 标记的 var 属性声明的资源包.

The value attribute of the p:toolTip component must be an EL expression or a literal text. Usually, one would reference a resource bundle declared using the var attribute of the f:loadBundle tag, in the EL expression for the tooltip.

使用 basename 属性声明的底层资源包可以由属性文件本身支持(在这种情况下,您需要将属性文件放在类路径上的适当目录中),或者为此它可以是一个自定义的 ResourceBundle 实现,它可以从属性文件(位于容器外部)、数据库或任何存储中读取.

The underlying resource bundle declared using the basename attribute could be backed by a property file itself (in which case you need to place the property file in the appropriate directory on the classpath), or for that matter it could be a custom ResourceBundle implementation that could read from a properties file (located outside the container), or a database or any store for that matter.

因此,您可以将现有的 EL 表达式从定义为:

You could therefore change your existing EL expression from the existing one defined as:

<f:loadBundle var="msg" basename="propfile_location" />

<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />

简而言之,您需要推出自己的 ResourceBundle 类以支持各种语言环境.无需说明,但您需要覆盖 ResourceBundle.getObject(java.lang.String) 方法,因为它由 ResourceBundleELResolver 在评估引用 ResourceBundles 的 EL 表达式时的实现.

In simpler words, you will need to roll your own ResourceBundle class(es) to support the various locales. Needless to state, but you will need to override the ResourceBundle.getObject(java.lang.String) method, as it is invoked by the ResourceBundleELResolver implementation when evaluating the EL expressions referencing ResourceBundles.

此外,您需要确保 ResourceBundle 的 ResourceBundle.getObject(java.lang.String) 实现将始终重新获取并返回与提供的键对应的值.未能确保这一点将意味着资源包获取的初始值可能会在后续调用中返回,尤其是在缓存初始值时.即使您部署了一个分解的 WAR 文件,您也可能会遇到这种行为,您可以在其中修改属性文件内容而无需重新部署应用程序,这就是为什么使用不缓存值的自定义 ResourceBundle 实现很重要的原因.

Additionally, you will need to ensure that the ResourceBundle.getObject(java.lang.String) implementation of your ResourceBundle will always re-fetch and return the value corresponding to the provided key. Failure to ensure this would mean that the initial value fetched by the resource bundle may be returned on subsequent invocations, especially if you are caching the initial value. You are likely to encounter this behavior even if you deploy an exploded WAR file where you can modify the property file contents without a redeployment of the application, and that is why it is important to use a custom ResourceBundle implementation that does not cache values.

这篇关于如何在不重启服务器的情况下动态更新 JSF2.0 (Primefaces) 工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆