Below is a brief overview of the features defined by
the SAS component model. This object model is defined by com.sas.ComponentInterface
and as implemented by com.sas.Component.
The model acts as a data source for one or more
views. Models normally send events when their state has changed.
The com.sas tree contains several support classes
which simplify the implementation of lists of event listeners within
models.
Several models are defined in the
com.sas.models and
com.sas.collection and
com.sas.table
packages.
Models for accessing data on SAS servers are in packages under com.sas.sasserver
The view
observes the model, reflecting changes in the model.
The view normally keeps track of its models, often
adding itself as a listener for events that the model generates.
Many visual components which act as views are found in
the com.sas.awt
and com.sas.visuals
packages. A view need not be a visual component.
The ComponentInterface provides a consistent way of identifying
these roles. Models implement the com.sas.ModelInterface
interface, and views implement the com.sas.ViewInterface
interface. The java.util.Observer
interface and java.util.Observable
base class provide an alternate implementation of Model/View, but
one which requires that the models extend from
java.util.Observable,
rather than simply implement an interface (like com.sas.ModelInterface).
The SAS component model supports dynamic model/view associations.
Views have required interfaces, which is a set of interfaces that
any model attached to the view must implement. For example, a
com.sas.awt.ListBox can act as a view
for any model which implements the required interface,
com.sas.collection.StaticOrderedCollectionInterface.
If the model is altered by adding or removing items, it will fire a
ContentsChangedEvent
and all views (i.e. the ListBox) will respond to the
event by updating their view automatically. Because of the
additional behavior provided by the SAS component arhcitecture
and the SAS component library, the amount of additional code
necessary to build highly functional applications is very small.
The webAF IDE allows you to establish model/view attachements by dropping an icon representing the model onto one or more icons representing views. The base component interface support classes enforce these required interfaces when a model is attached to a view.
An example of property linking is an applet which uses
two ListBox components to chose a SAS dataset from a SAS server.
The first ListBox displays a list of libraries which exist on the
server. (Attach a LibraryListInterface
as the model to the first ListBox).
The second listbox displays a list of datasets within
a specific library. (Attach a DataSetListInterface
as the model to the second ListBox). The selectedItem property
ListBox is linked to the library
property of a DataSetListInterface object.
When the user selects a library name in the first
ListBox, the string value
is automatically assigned to the library property
of the list of data sets via its setLibrary method.
The data set list then queries the server
for the list of data sets in that library and updates itself with
the list. Since the data set list is the model for the second
ListBox, when the data set list updates itself and
fires a change event, the view (the second list box) refreshes
with the new list contents: the list of data sets in the selected
library. All of this is performed automatically by Property Linking.
If the data types of the source and target properties do not match, a built in set of transforms can convert between Java types (primitive and object types).
The webAF IDE allows direct property linking via the user interface, so such links can be created without writing Java code.
The ComponentInterface also provides the support for implementing bound and constrained properties of Java Beans. ComponentInterface provides the implementation for managing a list of PropertyChangeListeners and for firing PropertyChangeEvents to those listeners.
Property Linking plays a critical role in developing event based or event driven applications. Most modern user interfaces are event based. Java 1.1 and Java Beans provide for and almost demand event based programming. Property Linking integrates well into this application model, allowing consistent application development.
com.sas component properties are bound properties.
That is, the component will fire a java.beans.PropertyChangeEvent
when the property is changed, either through an explicit assignment
via a set method in Java, or indirectly through a user
action such as editing text or through property linking.
SAS components are also Serializable as defined by the Java
java.io.Serializable
interface. ComponentInterface also implements
java.io.ObjectInputValidation
to assist in deserialization.
com.sas package:
com.sas.ComponentInterface
combines the smaller interfaces to define a highly functional
Java component (object) whcih supports extended Java Beans,
property linking, and Model/View frameworks.
com.sas.ModelInterface
defines the interface to the model portion of the Model/View
framework. A Model is an abstraction for data/service provide
which a view, defined by com.sas.ViewInterface, observes.
com.sas.ViewInterface
defines the interface to a view, which observes and potentially
updates a model. Views are typically, but need not be,
visual/graphical components such as user interface controls.
com.sas.LinkPropertiesInterface
defines the interface through which property linking is supported.
com.sas.PublicClonable
defines an interface to a Java component which can be cloned (copied)
via a public clone() method.
com.sas package:
com.sas.Component
defines the base class for SAS (or your own) componets
which implement the SAS component model. The Component class
provides a complete implementation of the com.sas.ComponentInterface
interface. Visual classes
derived from AWT cannot extend from this base class and instead
implement com.sas.ComponentInterface.
com.sas.ComponentInterfaceSupport
and
com.sas.ComponentInterfaceSupportInfo
provide the implementation of much of the functionality defined by
ComponentInterface.
com.sas.Component interfaces
com.sas.LinkPropertiesInterfaceSupport
provides implementation support for the com.sas.LinkPropertiesInterface.
com.sas.ComponentInterfaceSupport
and com.sas.ComponentInterfaceSupportInfo
provide implementation of com.sas.ComponentInterface.
com.sas.ViewInterfaceSupport
and com.sas.ViewInterfaceSupportInfo
provide implementation of com.sas.ViewInterface.
com.sas.ModelInterfaceSupport
provide implementation of com.sas.ModelInterface.
The Bean Extension Wizard takes an existing class and adds the
ComponentInterface behavior by creating a subclass which uses these
helper classes. For example, the Bean Extension Wizard was used
to extend the java.awt components as seen in the com.sas.awt package.