$URL: svn+ssh://christianc@svn.forge.objectweb.org/svnroot/barracudamvc/Barracuda2/trunk/WEB-INF/src_docs/quick_reference/index.html $ - $Revision: 125 $

Hello World 1a

This is a very simple Hello World example that demonstrates how to use the BTemplate component without even coding a model. Instead, we use a properties file (although in all fairness, you probably won't need to do this very often).

Spotting the Differences

First of all, notice that we're using the exact same template as we did in HelloWorld 1..

So, let's start by comparing the HelloWorld1a servlet with the previous example. A quick glance will reveal that the only real difference lies in how we are instantiating the Model. Rather than using an inner class, we are instead instantiating a DefaultPropertiesModel. This model takes a reference to a properties file name, in this case

org.enhydra.barracuda.tutorials.comp.HelloWorld

When the model receives a request for data, it looks for the key in the properties file and returns the corresponding value. Pretty simple.

Now, while you probably wouldn't want to do this for data that is dynamic to every request, it does make it easier to handle localization issues where localized static text values are stored in a file. The primary purpose of this example is just to show you how it can be done.


$Date: 2006-01-02 15:59:13 -0500 (Mon, 02 Jan 2006) $