ICEfaces
  1. ICEfaces
  2. ICE-2763

Add new ice:loadBundle component (locale of messages bundle cannot be changed dynamically)

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8DR#2, 1.8
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial

      Description

      Since <f:loadBundle> will cache the resource properties, changing the locale of the UIViewRoot dynamically does not cause the messages to update because the resource bundle is not reloaded. In order to reload the resource bundle, need to refresh the page or use redirect, but this causes a new UIViewRoot to be created and it will use the config and browser settings to determine the locale and load the bundle before the backing bean can set the locale of the ViewRoot.

      Need a custom loadBundle that will prevent the bundle from caching and allow messages bundle to dynamically change when the locale is changed

        Issue Links

          Activity

          Hide
          Mark Collette added a comment -

          Yes, I think it shows the need for an ice:loadBundle component, which will detect Locale changes, and uncache old ResourceBundles appropriately.

          Show
          Mark Collette added a comment - Yes, I think it shows the need for an ice:loadBundle component, which will detect Locale changes, and uncache old ResourceBundles appropriately.
          Hide
          Ted Goddard added a comment -

          An ice:loadBundle component would also simplify the Bridge since bundles would not need to be propagated in the requestMap.

          Show
          Ted Goddard added a comment - An ice:loadBundle component would also simplify the Bridge since bundles would not need to be propagated in the requestMap.
          Hide
          Woolfgang Schuh added a comment -

          To use use ICE-Faces in an WEB-Application with international accounts/Users, it is a "MUST" to
          to solve this problem.

          Show
          Woolfgang Schuh added a comment - To use use ICE-Faces in an WEB-Application with international accounts/Users, it is a "MUST" to to solve this problem.
          Hide
          David Josep added a comment -

          It should compatible to use with actual MessageBundleLoader to avoid to change the current code.

          Show
          David Josep added a comment - It should compatible to use with actual MessageBundleLoader to avoid to change the current code.
          Hide
          Krashan Brahmanjara added a comment -

          Using f:loadBundle or ice:loadBundle is completely not necessary!
          For good performance use features of jsf.1.2

          <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
          (...)
          <application>
          (...)
          <resource-bundle>
          <base-name>...messages</base-name>
          <var>msg1</var>
          </resource-bundle>
          <resource-bundle>
          <base-name>...messages2</base-name>
          <var>msg2</var>
          </resource-bundle>
          (...)
          <application>
          (...)

          Show
          Krashan Brahmanjara added a comment - Using f:loadBundle or ice:loadBundle is completely not necessary! For good performance use features of jsf.1.2 <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd "> (...) <application> (...) <resource-bundle> <base-name>...messages</base-name> <var>msg1</var> </resource-bundle> <resource-bundle> <base-name>...messages2</base-name> <var>msg2</var> </resource-bundle> (...) <application> (...)
          Hide
          Klaus Stake added a comment -

          @Krashan: it is necessary! For example we have an application where we dynamically change theme and language. We need to dynamically change the message bundles. Which seems not to be possible the way you described.

          Show
          Klaus Stake added a comment - @Krashan: it is necessary! For example we have an application where we dynamically change theme and language. We need to dynamically change the message bundles. Which seems not to be possible the way you described.
          Hide
          Paul van Rossem added a comment -

          I also use the resource bundle as explained by Krashan. That really, really works. I remember the user's locale in a bean and specify it to the view root in <f:view locale="#

          {bean.locale}

          " ... >. Just let the user alter the locale property in the bean by clicking a flag or so and on the next page reload you see the new language. No problem. No need to fuzz around with the message bundles. All taken care of by JSF. Or is this not what you want?

          Show
          Paul van Rossem added a comment - I also use the resource bundle as explained by Krashan. That really, really works. I remember the user's locale in a bean and specify it to the view root in <f:view locale="# {bean.locale} " ... >. Just let the user alter the locale property in the bean by clicking a flag or so and on the next page reload you see the new language. No problem. No need to fuzz around with the message bundles. All taken care of by JSF. Or is this not what you want?
          Hide
          Adnan Durrani added a comment -

          ice:loadBundle added to the trunk:

          Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\conf\META-INF\faces-config.xml
          Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle
          Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle\LoadBundle.java
          Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\utils\MessageUtils.java
          Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-component.xml
          Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-renderer.xml
          Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\extended-faces-config.xml
          Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-loadbundle-props.xml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-renderer.xml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle\LoadBundle.java
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\utils\MessageUtils.java
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-loadbundle-props.xml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\conf\META-INF\faces-config.xml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\extended-faces-config.xml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-component.xml
          Completed: At revision: 17868

          Show
          Adnan Durrani added a comment - ice:loadBundle added to the trunk: Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\conf\META-INF\faces-config.xml Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle\LoadBundle.java Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\utils\MessageUtils.java Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-component.xml Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-renderer.xml Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\extended-faces-config.xml Adding: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-loadbundle-props.xml Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-renderer.xml Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\loadbundle\LoadBundle.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\utils\MessageUtils.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\ice_cust_properties\cust-loadbundle-props.xml Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\conf\META-INF\faces-config.xml Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\extended-faces-config.xml Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component-metadata\src\main\resources\conf\custom\loadbundle-component.xml Completed: At revision: 17868
          Hide
          Klaus Stake added a comment -

          @Paul and Krashan: You're right. For my purposes I can really use standard JSF means. I've just given it a try. Sorry for my doubts.

          Show
          Klaus Stake added a comment - @Paul and Krashan: You're right. For my purposes I can really use standard JSF means. I've just given it a try. Sorry for my doubts.
          Hide
          Adnan Durrani added a comment -

          locale changes respected. revision 17870

          Show
          Adnan Durrani added a comment - locale changes respected. revision 17870
          Hide
          Adnan Durrani added a comment -

          TLDDocs added: revision 17874

          Show
          Adnan Durrani added a comment - TLDDocs added: revision 17874
          Hide
          Krashan Brahmanjara added a comment -

          Locale with <resource-bundle> works well.

          I think that this new feature will start a new set of problems for not advanced users.

          Show
          Krashan Brahmanjara added a comment - Locale with <resource-bundle> works well. I think that this new feature will start a new set of problems for not advanced users.
          Hide
          Ken Fyten added a comment -

          The new ice:loadBundle component added to the trunk. Its provides two dynamic features:

          1- the message bundle base can be changed dynamically. (So you can change entire messages bundle)
          2- if the "locale" has changed on ViewRoot dynamically, it reloads the bundle for the corresponding locale.

          Feature "1" is working fine, but feature "2" is not working due to the fact that we use the same ViewRoot on each request for the same page and in the D2DViewHandler there is a call "setLocale" on viewRoot which cache the locale into the viewRoot, so the getViewRoot always returns the cached locale and doesn't respect the value binding. This is captured in ICE-3755.

          Show
          Ken Fyten added a comment - The new ice:loadBundle component added to the trunk. Its provides two dynamic features: 1- the message bundle base can be changed dynamically. (So you can change entire messages bundle) 2- if the "locale" has changed on ViewRoot dynamically, it reloads the bundle for the corresponding locale. Feature "1" is working fine, but feature "2" is not working due to the fact that we use the same ViewRoot on each request for the same page and in the D2DViewHandler there is a call "setLocale" on viewRoot which cache the locale into the viewRoot, so the getViewRoot always returns the cached locale and doesn't respect the value binding. This is captured in ICE-3755.
          Hide
          Adnan Durrani added a comment -

          demo added

          Show
          Adnan Durrani added a comment - demo added
          Hide
          Adnan Durrani added a comment -

          Not working with JSF 1.1

          Show
          Adnan Durrani added a comment - Not working with JSF 1.1
          Hide
          Adnan Durrani added a comment -

          support added for JSF 1.1
          trunk revision 17918

          Show
          Adnan Durrani added a comment - support added for JSF 1.1 trunk revision 17918

            People

            • Assignee:
              Unassigned
              Reporter:
              Jacky Lee
            • Votes:
              14 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: