Continuing from my previous post, you might also want to add some application variables that you can access in your views easily.

To start with, ModelGlue comes with a generic bean that you can use to setup some values without having to create your own beans. You set this in the Coldspring.xml file and in this example, I am going to add some site wide information, such as a copyright value that will go in the footer.

2007 Mark Drew Inc. PLC. SA. PTY. Ltd. http://www.markdrew.co.uk

What we have done here is set up an object called copyrightConfig with some values in it. The <map> item is actually setting up a structure.

Now that we have a bean with our application wide configuration settings, we would like to put them available to all the views via the ViewState object. To do this, in the default controller we add code to the onRequestStart function to load our bean and put it in the ViewState:

The first line gets the copyrightConfig bean's config structure (remember those values we added to the <map>?), then we loop through the keys in the structure (adding "copyright_" to the start, just so we know what they are) adding them to the event object. Later on in the view, we have available in the viewState the values as follows:

If you don't like adding the "copyright_" to each of the values you could add the configuration structure to the the copyright key:

And then access the items as follows:

the only thing is that by accessing the values like this, you are taking away the in-built help that the ViewState.getValue() function gives you that if the value doesn't exist, it doesn't barf.