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

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

问题描述

我需要在不重新启动服务器的情况下动态更新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类来支持各种语言环境.无需说明,但您将需要覆盖 解决方案

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屋!

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