Announcement Announcement Module
Collapse
No announcement yet.
Getting html element names from a file outside the war Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting html element names from a file outside the war

    What is the best way to get html element names from a file (.properties) outside the war?

    We have different environments where different fields, drop-down options, check boxes will have different text.
    Ex.
    Env1
    Point : (input box)
    Location: (drop-down)
    loc1
    loc2
    loc3


    Env2
    BBOX: (input box)
    Location : (drop-down)
    loc4
    loc5
    loc6

    So we would have a separate property file for each environment.

    Can I use the messages.properties and then do:
    <fmt:message key="menu.loc"/> for the element in the jsp
    And then have the messages.properties outside the war?

    in the servlet-context.xml:
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="somewhere outside the war" />
    </bean>

    Or is there a better way?

    Thanks!
    Last edited by msimonian77; Jan 31st, 2012, 07:11 PM.

  • #2
    You can put the location of your properties file onto the server classpath and you should be able to access it using

    Code:
    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
         <property name="basename" value="classpath: nameOfPropertiesFile" />
    </bean>
    If you are using Websphere, you can setup a "Shared Library" in the admin console that points to a folder, this will add it to your server classpath.

    Another (better IMHO) way would be to use a build tool like Maven. Using profiles in Maven, you are able to define all the entries in your properties files as variables. When you build for a specific environment, Maven will write the environment specific values into your properties file. That way you will have only 1 properties file for each environment (although you will have a separate ear/war for each environment).

    hope that helps.

    Comment


    • #3
      Thanks for the fast reply!

      We can't use the maven solution as we only build in one environment.
      We prefer to have like a property file outside the war that we can easily modify when we deploy to the other environment.
      We are using Tomcat 7 as our server.

      Please let me know if the solution I mentioned above is the best one or if there is something better.

      Thanks!!!

      Comment


      • #4
        Originally posted by knoxor View Post
        You can put the location of your properties file onto the server classpath and you should be able to access it using

        Code:
        <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
             <property name="basename" value="classpath: nameOfPropertiesFile" />
        </bean>
        If you are using Websphere, you can setup a "Shared Library" in the admin console that points to a folder, this will add it to your server classpath.

        Another (better IMHO) way would be to use a build tool like Maven. Using profiles in Maven, you are able to define all the entries in your properties files as variables. When you build for a specific environment, Maven will write the environment specific values into your properties file. That way you will have only 1 properties file for each environment (although you will have a separate ear/war for each environment).

        hope that helps.


        We can't use the maven solution as we only build in one environment.
        We prefer to have like a property file outside the war that we can easily modify when we deploy to the other environment.
        We are using Tomcat 7 as our server.


        ___________________________________

        wholesale jerseys
        nike nfl jerseys
        Cheap Pro Jerseys

        Comment


        • #5
          Have you tried to add the properties file to Tomcat's lib directory. Your app should be able to pick that up as it's in the CLASSPATH.

          Comment


          • #6
            Have a look at this

            http://stackoverflow.com/questions/1...mcat-classpath

            Comment

            Working...
            X