UniVista Programmer's Guide

UniVista.beans

VariableBean


Intent | Structure | Participants | Sample Code | Known Uses

Intent

This class extends Variable. The reason for being a bean is due to its capability of listening to property changes. This support is easily attained by encapsulating a PopertyChangeSupport and VetoableChangeSupport (both can be found in java.beans). The veto support is for allowing other registered components to 'veto' any change that may have occured somewhere else.

In addition, a Hashtable is used to store any pluggable display beans, so at run time a Variable's UI is selectable. The pairs are stored as (String name, String className). className is necessary to anonymously load the display bean via a ClassLoader or using the forName method.

See Variable for details about the other properties.

Structure

Participants

Sample Code

One of the main features is the ability to listen to property changes. Below, a snippet is shown how a VariableBean registers with another component to listen for property changes. Note, 'listening' can be done via custom Events or by the generic PropertyChangeEvent, which allows inquiry of the property name.
//..
((VariableBean)theVar).addPropertyChangeListener((VariableDisplay)theVarUI);
The following code shows how to intercept and react to a property change.
public void propertyChange(PropertyChangeEvent event) {
String property = event.getPropertyName();

if (property.equals("namelistGroup")) {
setNamelistGroup((String)event.getNewValue());

//..

Known Uses

Throughout UniVista, all presently functioning Variables are actually subclasses of VariableBean.

VariableBeans are registered with display beans within the class UniVista.support.screens.VariableScreenObject. This is where the first code excerpt above was obtained. Currently, that is the only place that VariableBeans register to listen for changes (it could also have been done in their customizers, but a different approach was used).



Contact the UniVista Team | Main Page | Table of Contents