Barracuda Component Model Tutorial - HelloWorld 1a

<<|Preface|HelloWorld 1|1a|1b|2|2a|2b|3|4|>>

barracuda.gif (11456 bytes) Hello World 1a - this is a very simple example that demonstrates how to use a BTemplate component without even coding a model. Instead, we use a properties file.

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.

Click here to return to the Barracuda Component Model Tutorial page.

For all the latest information on Barracuda, please refer to http://barracuda.enhydra.org
Questions, comments, feedback? Let us know...
Copyright 1997-2002 Lutris Technologies, Inc. All rights reserved.