com.iplanet.jato.view
Class DisplayFieldImpl

java.lang.Object
  |
  +--com.iplanet.jato.view.ViewBase
        |
        +--com.iplanet.jato.view.DisplayFieldImpl
All Implemented Interfaces:
DisplayField, View
Direct Known Subclasses:
BooleanDisplayFieldImpl, CommandFieldBase, HtmlDisplayFieldBase

public class DisplayFieldImpl
extends ViewBase
implements DisplayField

Defines a subclass of ViewBase which adds support for the DisplayField interface. A DisplayField is a view that is capable of storing and retreiving an associated arbitrarily complex value object. The value may be singular or plural. If singular, the getValues() method will return an Object array of size one.

This implementation of the DiplayField interface uses a Model object for the storage of its values. The DisplayField can be said to be "bound" to a Model field. The DisplayField does not maintain a copy of the value(s) stored int its bound model field. Rather, the bound model field IS the DisplayField's value. Once the binding is in effect, changes to the Model's field have direct and immediate impact on the DisplayField and vice versa.

It is important to note that this implementation of DisplayField assumes that a display field is ALWAYS bound to a model.

Important note on DisplayFieldDescriptor Additionally, a DisplayField may be configured via a DisplayFieldDescriptor. The DisplayFieldDescriptor pattern allows developers to set and get many attributes of a DisplayField simply, without having to expand the DisplayField interface for every additional attribute. However, it is up to the implementation of the DisplayField class to take advantage of a DisplayFieldDescriptor. Constructors or other methods which require a non-null DisplayFieldDescriptor should state this explicitly, in their documentation. In the absence of an explicit directive, developers can assume that a null value may be supplied to any method parameter of type DisplayFieldDescriptor.

Version:
JATO/1.2.2 $Id: DisplayFieldImpl.java,v 1.10 2002/03/16 03:26:40 todd Exp $
See Also:
View, DisplayFieldDescriptor, DefaultModel

Fields inherited from interface com.iplanet.jato.view.View
QUALIFIED_VIEW_NAME_SEPARATOR
 
Constructor Summary
DisplayFieldImpl(ContainerView parent, java.lang.String name, java.lang.Object value)
          Construct a display field with the specified properties.
DisplayFieldImpl(ContainerView parent, java.lang.String name, java.lang.String boundName, java.lang.Object value)
          Construct a display field with the specified properties.
DisplayFieldImpl(View parent, Model model, java.lang.String name, java.lang.Object value)
          Construct a display field with the specified properties
DisplayFieldImpl(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object value)
          Construct a display field with the specified properties
DisplayFieldImpl(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object value, DisplayFieldDescriptor descriptor)
          Construct a display field with the specified properties
 
Method Summary
 java.lang.String getBoundName()
          Returns the name of the field in the Model object to which this display field is "bound".
 DisplayFieldDescriptor getDescriptor()
          Returns the DisplayFieldDescriptor
 Model getModel()
          Returns the Model object to which this display field is "bound"
 java.lang.Object getValue()
          Returns the first value in the value array
 java.lang.Object[] getValues()
          Returns the DisplayField's value array
 void setBoundName(java.lang.String value)
          Sets the name of the field in the Model object to which this display field is "bound".
 void setDescriptor(DisplayFieldDescriptor descriptor)
          Sets this objects DisplayFieldDescriptor
protected  void setModel(Model value)
          Set the Model object to which this display field is "bound"
 void setValue(java.lang.Object value)
          Sets the DisplayField value In effect this will set the value array size to one.
 void setValue(java.lang.Object value, boolean overwrite)
          Sets the DisplayField value to the new value only if the overwrite param is true or the the value is currently not set.
 void setValues(java.lang.Object[] values)
          Sets the DisplayField value array
 void setValues(java.lang.Object[] values, boolean overwrite)
          Sets the DisplayField value array to the new value array only if the overwrite param is true or the the value is currently not set.
 java.lang.String stringValue()
          This method returns either the toString() representation of a non-null displayField's value, or a blank string whenever the value is null
 
Methods inherited from class com.iplanet.jato.view.ViewBase
getName, getParent, getParentViewBean, getQualifiedName, getRootView, getRootView, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.iplanet.jato.view.View
getName, getParent, getQualifiedName, setParent
 

Constructor Detail

DisplayFieldImpl

public DisplayFieldImpl(ContainerView parent,
                        java.lang.String name,
                        java.lang.Object value)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name and model field bound name
value - This DiplayField's initial value.

DisplayFieldImpl

public DisplayFieldImpl(ContainerView parent,
                        java.lang.String name,
                        java.lang.String boundName,
                        java.lang.Object value)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.

DisplayFieldImpl

public DisplayFieldImpl(View parent,
                        Model model,
                        java.lang.String name,
                        java.lang.Object value)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name and model field bound name
value - This DiplayField's initial value.

DisplayFieldImpl

public DisplayFieldImpl(View parent,
                        Model model,
                        java.lang.String name,
                        java.lang.String boundName,
                        java.lang.Object value)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name.
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.

DisplayFieldImpl

public DisplayFieldImpl(View parent,
                        Model model,
                        java.lang.String name,
                        java.lang.String boundName,
                        java.lang.Object value,
                        DisplayFieldDescriptor descriptor)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name.
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.
descriptor - This DisplayField's DisplayFieldDescriptor. May be null.
Method Detail

getModel

public Model getModel()
Returns the Model object to which this display field is "bound"
Returns:
the DisplayField's bound Model

setModel

protected void setModel(Model value)
Set the Model object to which this display field is "bound"
Parameters:
the - Model to which one wishes to bind the DisplayField

getBoundName

public java.lang.String getBoundName()
Returns the name of the field in the Model object to which this display field is "bound". Note, this is not a qualified name, in that it does not include the model name.
Returns:
The name of the field in the Model object to which this display field is "bound"

setBoundName

public void setBoundName(java.lang.String value)
Sets the name of the field in the Model object to which this display field is "bound". Note, this is not a qualified name, in that it does not include the model name.

getDescriptor

public DisplayFieldDescriptor getDescriptor()
Returns the DisplayFieldDescriptor
Specified by:
getDescriptor in interface DisplayField
Returns:
this object's DisplayFieldDescriptor

setDescriptor

public void setDescriptor(DisplayFieldDescriptor descriptor)
Sets this objects DisplayFieldDescriptor
Parameters:
descriptor - The DisplayFieldDescriptor

getValue

public java.lang.Object getValue()
Returns the first value in the value array
Specified by:
getValue in interface DisplayField
Returns:
the first value in the DisplayFields value array

setValue

public void setValue(java.lang.Object value)
Sets the DisplayField value In effect this will set the value array size to one.
Specified by:
setValue in interface DisplayField
Parameters:
aValue - The object that will be stored as the DisplayField's value

setValue

public void setValue(java.lang.Object value,
                     boolean overwrite)
Sets the DisplayField value to the new value only if the overwrite param is true or the the value is currently not set. In effect this will set the value array size to one.
Parameters:
value - The object that will be stored as the DisplayField's value
overwrite - specifies whether to overwrite the old value with a new one

getValues

public java.lang.Object[] getValues()
Returns the DisplayField's value array
Specified by:
getValues in interface DisplayField
Returns:
the DisplayField's value array

setValues

public void setValues(java.lang.Object[] values)
Sets the DisplayField value array
Specified by:
setValues in interface DisplayField
Parameters:
aValue - The object array that will be stored as the DisplayField's value

setValues

public void setValues(java.lang.Object[] values,
                      boolean overwrite)
Sets the DisplayField value array to the new value array only if the overwrite param is true or the the value is currently not set.
Parameters:
values - The objects that will be stored as the DisplayField's value
overwrite - specifies whether to overwrite the old value with a new one

stringValue

public java.lang.String stringValue()
This method returns either the toString() representation of a non-null displayField's value, or a blank string whenever the value is null
Specified by:
stringValue in interface DisplayField
Returns:
a string representation of the value, guaranteed to be non-null