如何在不重新启动服务器的情况下动态更新JSF2.0(Primefaces)工具提示 [英] How to update the JSF2.0 (Primefaces) tooltips dynamically without server restart
问题描述
我需要在不重新启动服务器的情况下动态更新JSF2.0(Primefaces)工具提示.
这意味着需要找到一种方法,可以在不重新启动服务器的情况下更改正在运行的应用程序的工具提示(属性文件中的atm).
我们正在运行Websphere并部署非爆炸EAR(可能可以说服部署爆炸战争)
请提出任何想法或提示.谢谢你
p:toolTip
组件的value
属性必须是EL表达式或文字文本.通常,将在工具提示的EL表达式中引用使用f:loadBundle
标签的var
属性声明的资源包.
使用basename
属性声明的基础资源束可以由属性文件本身支持(在这种情况下,您需要将属性文件放置在类路径上的相应目录中),或者它可以是自定义ResourceBundle实现,可以从属性文件(位于容器外部),数据库或与此相关的任何存储中读取.
因此,您可以从定义为以下内容的现有EL表达式更改现有的EL表达式:
<f:loadBundle var="msg" basename="propfile_location" />
到
<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />
用简单的话来说,您将需要滚动自己的ResourceBundle类来支持各种语言环境.无需说明,但您将需要覆盖 ResourceBundleELResolver
实现,当评估引用ResourceBundles的EL表达式时.
此外,您将需要确保ResourceBundle的ResourceBundle.getObject(java.lang.String)
实现将始终重新获取并返回与提供的键相对应的值.无法确保这将意味着在后续调用中可能返回由资源束获取的初始值,尤其是在缓存初始值的情况下.即使部署展开的WAR文件,您可以在不重新部署应用程序的情况下修改属性文件的内容,您也可能会遇到此行为,这就是为什么使用不缓存值的自定义ResourceBundle实现很重要的原因. /p>
I need to update the JSF2.0 (Primefaces) tooltips dynamically without server restart.
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.
We are running websphere and deploying a non exploded EAR (can probably convince to deploy exploded war)
Any Ideas or tips please. Thanks you
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.
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.
You could therefore change your existing EL expression from the existing one defined as:
<f:loadBundle var="msg" basename="propfile_location" />
to
<f:loadBundle var="msg" basename="fully qualified class name of the ResourceBundle class" />
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.
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屋!