resource bundles...

Discussion in 'Java' started by pojo, Feb 22, 2006.

  1. pojo

    pojo Guest

    I want to improve my code using resource bundles. I have fields like
    no: of companies
    no: of places..etc.,
    I want to use resource bundles and put the key value pair like

    No: of comapanies = 12
    no: of places = 50 ..etc., in a file and use the keys whenever i have
    to use the values.

    can someone walk me through this...with details like..
    what should be the file name for these fields..
    where should I put the file name...
    what changes hould I make to the config files...etc.,

    I am not using struts.
    I am using JBoss and Intellij IDEA.

    thanks,
    pojo, Feb 22, 2006
    #1
    1. Advertising

  2. pojo

    Rhino Guest

    "pojo" <> wrote in message
    news:...
    >I want to improve my code using resource bundles. I have fields like
    > no: of companies
    > no: of places..etc.,
    > I want to use resource bundles and put the key value pair like
    >
    > No: of comapanies = 12
    > no: of places = 50 ..etc., in a file and use the keys whenever i have
    > to use the values.
    >
    > can someone walk me through this...with details like..
    > what should be the file name for these fields..
    > where should I put the file name...
    > what changes hould I make to the config files...etc.,
    >
    > I am not using struts.
    > I am using JBoss and Intellij IDEA.
    >

    I'm not sure if you really need to use resource bundles for the data that
    you describe; it sounds to me like you'd be fine just using regular
    Properties files. Storing your data in Preferences nodes or in a database
    may also be good approaches.

    However, if you are sure that those other options are inappropriate, I think
    you will find that the Internationalization "trail" (chapter) in the Java
    Tutorial covers this topic pretty well. You can find it at
    http://java.sun.com/docs/books/tutorial/i18n/index.html.

    I've only tried using ResourceBundles with applications and applets so I'm
    not sure if servlets or JBoss or IDEA add any complications; the exact
    placement of the ResourceBundles may differ in those environments. Someone
    else may be able to tell you about that.

    The tutorial will explain that you can use ResourceBundles to store
    information in key-value pairs in both Message and Text bundles; the Text
    bundles are the closest to what you want; they are structured just like
    Properties files but give you the option of having multiple concurrent
    versions of your text in different languages so that your applications can
    support multiple languages with minimum of effort.

    --
    Rhino
    Rhino, Feb 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M Series
    Replies:
    0
    Views:
    346
    M Series
    Oct 20, 2003
  2. Replies:
    4
    Views:
    11,983
  3. Replies:
    0
    Views:
    394
  4. enrique

    Why resource bundles

    enrique, Apr 17, 2007, in forum: Java
    Replies:
    1
    Views:
    339
    Wojtek
    Apr 17, 2007
  5. Marco

    cross-jars resource bundles

    Marco, Oct 13, 2009, in forum: Java
    Replies:
    4
    Views:
    718
    Roedy Green
    Oct 14, 2009
Loading...

Share This Page