How to centralize Web Project properties in a configuration file

From WebRatio WebML Wiki

Jump to: navigation, search


Introduction

When designing Web Projects, often the use of static values are required, such as values of conditions, passing of static values in Links Coupling, values in configuration Properties of the Units, etc. The problem of the usage of static values is that they may vary according to the environment in which the application is deployed (such as Web Services URLs in test environments and in production environments). WebRatio resolves this issue providing the WebRatio.properties file. This file contains a list of key-value pairs representing all the static values (the value of the pairs) of a Web Project giving a name to each (the key of the pairs). Those keys can then be used in the Web Project as placeholders instead of the proper values. In the generated Web application, at startup, all the keys are replaced with the corresponding values, in order to make the Web application work properly.

The structure of the WebRatio.properties file

In order to configure it correctly, the WebRatio.properties file must be placed, in the Web Project folder, in Web Content/WEB-INF/classes. The property file itself must have the same structure of a normal Java property file. Here's an example:

highlightedProductOfTheDay=true
highlightedCategoryOfTheDay=true
allProductsMaxResults=150
getDataWebService=http://webservices.daehosting.com/services/TemperatureConversions.wso

Remember that in properties files:

  • each line must contain a single property
  • comments must begin with "!" or "#"
  • spaces must be escaped with "\ "
  • The encoding is ISO-8859-1, also known as Latin-1. All non-Latin-1 characters must be entered by using Unicode escape characters

How to use the properties in the Web Project

once the WebRatio.properties file has been defined, it's possible to replace every static value in:

  • the Properties panel of the Units
  • in the Value Property of Conditions
  • in Link Couplings

with the corresponding key simply replacing the value with "${Name of the key}". Has example, referring to the WebRatio.properties file shown above, it's possible to change the Home Page of the Acme project:

Home page with static values
 

using the properties:

Home page with properties
 

Or the Max Results Property of the All Stores Index Unit:

Index Unit Properties with static values
 

using the property:

Index Unit Properties with properties
 

Or a Link Coupling:

Link Coupling with static values
 

using the property:

Link Coupling with properties
 


Related articles:
Category Difficulty Refers
Can I integrate a manually written JSP page in a WebRatio application? Integration Advanced Web Application
Debugging with application's logs Web Model Intermediate Web Application
How can I configure runtime properties (e.g. upload directory)? Deployment Beginner Web Application
How can I increase memory in my application server? Deployment Beginner Web Application
How can I manage non ISO-8859-1 characters passing on the URL? Deployment Intermediate Web Application
… further results












Did you find this article useful? Please rate it!

Rating: 0.0/5 (0 votes cast)

Personal tools