0 Replies Latest reply on Oct 9, 2001 9:08 AM by alu1344

    How to link two ResourceBundles via parent property

    alu1344

      I have two ResourceBundles that I would like to link (better than trying to re-invent the wheel via any pattern such as facade).

      The point is, I have a "general" ResourceBundle with the general error messages of my architecture (such as "parameter not found", and "out of bounds") and another "particular" one for the concrete application .war (such as "customer not available", or whatever).

      I can keep both separate, but am thinking about linking both (via the parent property), but at the same time keep the properties files (I don't like very much the idea of having to implement a ResourceBundle subclass for every Locale).

      The setParent method is protected and that forces me to implemet child classes, but I got lost in the API. This far I am mostly convinced that doing this is impossible without reimplementing the ResourceBundle class.

      An example of what I am trying to do:

      file://com/mycompany/resources.properties:
      mymessage1 = Parameter not found

      file://com/myclient/resources.properties
      mymessage2 = Customer not available

      ResourceBundle rb = ResourceBundle.get("com.client.resources", new Locale("en"));
      rb.getString("mymessage1");

      Properly implemented, that code would return "Parameter not found"