WebSphere 7 上 JSF 项目的内部化
我正在尝试按照示例实现从数据库加载 JSF 应用程序的资源包: JSF 中的国际化,使用从数据库加载的 ResourceBundle 条目
对于测试,我编写了 getItSomehow() 就像创建 HashMap 并用键填充它一样“hello_world”和值“[”+locale+”]”+“hello world”
当我将其部署在 Glassfish3 上时,该示例工作正常。 但是当我使用WebSphere AS 7时,jsf页面仅在第一次时才能正确显示。在其他浏览器中打开 jsf 页面(选择其他首选语言)我总是在首次运行的区域设置中收到响应。
在调试时,我发现ResourceBundle.java的实现存在差异:Glassfish使用了JDK1.6的rt.jar中提供的这个类;但 WebSphere 在 java.util.jar 中有这个类
从 ApplicationResourceBundle.getResourceBundle() 调用的 ResourceBundle(WebSphere 的)调用 handleGetBundle() 并最终调用 my.i18n.DbResourceBundle$DBControl.newBundle() 。 使用不同的区域设置第二次(以及进一步)调用它不会调用我的覆盖,而只是返回为第一个区域设置创建的相同包。
问题:是否可以编写部署在 WebSphere AS 7.0.07 上的可内部化的 jsf Web 应用程序,而不需要挖掘或侵入 AS 的内部?
(环境:Windows XP、WebSphere AS 7.0.0.7、jdk1.6.0_24、jsf 2.1.4)
I'm trying to implement loading Resource Bundles for JSF application from DB, following the sample: internationalization in JSF with ResourceBundle entries which are loaded from database
For the test I coded getItSomehow() just as create HashMap and fill it with key "hello_world" and value "["+locale+"]"+"hello world"
The sample works fine when I deploy it on Glassfish3.
But when I use WebSphere AS 7, the jsf page is displayed correctly only for the first time. Opening the jsf page in other browsers (with other prefered language selected) I receive the respond always in the locale of first run.
While debugging, I found the difference in implementation of ResourceBundle.java: Glassfish uses this class provided in rt.jar of the JDK1.6; but WebSphere has this class inside java.util.jar
The ResourceBundle (of WebSphere) called from ApplicationResourceBundle.getResourceBundle() calls handleGetBundle() and finally invokes my.i18n.DbResourceBundle$DBControl.newBundle() .
Called second (and further) time with different locale it doesn't invoke my override but just returns the same bundle created for first locale.
The question: is it possible to code internalizable jsf web-application deployed on WebSphere AS 7.0.07, not digging nor hacking into internals of the AS?
(environment: Windows XP, WebSphere AS 7.0.0.7, jdk1.6.0_24, jsf 2.1.4)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以提供ResourceBundle的具体实现。
下面是每次 JSF 调用 ResourceBundle 方法时获取当前语言环境的示例:
并在 faces-config.xml 中输入:
我们遇到了同样的问题,该解决方案适用于 Windows Server 2008、WebSphere AS 7.0.0.19、jdk1。 6.0_29、jsf 2.1.5
You can provide a specific implementation of ResourceBundle.
Here an example that gets the current locale each time JSF invokes the ResourceBundle methods:
and in your faces-config.xml put:
We had your same problem and this solution worked for us with Windows Server 2008, WebSphere AS 7.0.0.19, jdk1.6.0_29, jsf 2.1.5