net.sf.jzeno.echo.databinding
Class DynaListBox

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by net.sf.jzeno.echo.components.CustomComponent
          extended by net.sf.jzeno.echo.databinding.DynaListBox
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, BindingTarget, ListBoxInterface, PropertyComponent, RebindableComponent, EventSink, EventSource, Precreation, CollectionChangeListener, Component, ActionListener, ListDataListener, ListSelectionListener, FastComponent, FastComponentContainer
Direct Known Subclasses:
DynaSelectField

public class DynaListBox
extends CustomComponent
implements ListDataListener, ListSelectionListener, EventSource, ActionListener, FastComponent, ListBoxInterface, Precreation, CollectionChangeListener

Allows the user to select one or more items from a list of possible items. This list is shown in a list box. The items being displayed are a list of java beans (setList(List)). Of those java beans you can specify a property that is shown to the user on the screen setLabelProperty(String)). When the users has selected one or more from the possible options, the java beans from the original list that were selected will be written to the data binding target of this component.

You can configure this component to allow only a single selection, or to allow multiple selections (setMultiSelect(boolean)- by default false ).

If you allow only one item to be selected, you should bind this component to a property of the type corresponding to the type of the java beans in the list of all possible items.

If on the other hand you do allow multiple selection, than this component should be bound to a property of type java.util.Collection .

See Also:
Serialized Form

Nested Class Summary
 class DynaListBox.DefaultValidator
           
 
Field Summary
 java.lang.String cssClass
           
static int PERCENT_UNITS
           
static int PIXEL_UNITS
           
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
DynaListBox()
           Creates an unbound component.
DynaListBox(java.lang.Class beanClass, java.lang.String propertyName, java.lang.String constructionHints)
           Creates a databound listbox.
 
Method Summary
 void actionPerformed(ActionEvent e)
           Gets the dynamic event handler that will be triggered when a selection is made in the listbox.
 void applyContext()
           
 void changed(java.util.Collection collection)
           
 void clearSelection()
           Clears any selection on the component.
 void contentsChanged(ListDataEvent arg0)
           Used internally.
 java.lang.String getActionCommand()
           
 Color getBackground()
           Gets the background color of this listbox.
 java.util.Comparator getComparator()
           
 java.lang.String getCssClass()
           
 Decorator getDecorator()
          Implementation of RebindableComponent
 Font getFont()
          Returns the font.
 Color getForeground()
           Gets the foregound color (text in the listbox) of this listbox.
 java.lang.String getInvalidMessage()
           Gets the message key that is added to the screen, when the component is marked as invalid.
 java.lang.String getInvalidMessageKey()
          Deprecated.  
 java.lang.String getLabelProperty()
           Gets the property (path), used to show the java beans in the list, on the screen.
 java.util.List getList()
           Gets the list of java beans the user can select from.
 ListModel getModel()
           Gets the model that is used by this listbox.
 java.lang.String getNullLabel()
           Gets the label, corresponding to the data binding target value null.
 int getSelectedIndex()
           Gets the index that is selected.
 java.lang.Object getSelectedItem()
          
 java.lang.String getSelectedLabels()
          Returns the label that the user selected.
 java.lang.Object getSelectedValue()
          Deprecated.  
 java.lang.String getToolTipProperty()
           Gets the tooltip indirectly by specifying a property path.
 java.lang.String getToolTipText()
           Gets the tooltip that appears when the user hoovers over this component.
 int getVisibleRowCount()
           Gets the number of items that are shown in the listbox at once.
 int getWidth()
           
 int getWidthUnits()
           
 void intervalAdded(ListDataEvent arg0)
           Used internally.
 void intervalRemoved(ListDataEvent arg0)
           Used internally.
 boolean isAsync()
           
 boolean isDoubleClickActionCommand()
           
 boolean isMultiSelect()
           Gets whether or not the listbox allows multiple items to be selected.
 boolean isReadOnly()
           
 void rebind()
           This operation causes the component to reset it's content to that of the domain model.
 void setActionCommand(java.lang.String command)
           Sets the dynamic event handler that will be triggered when a selection is made in the listbox.
 void setAsync(boolean async)
           
 void setBackground(Color background)
           Sets the background color of this listbox.
 void setComparator(java.util.Comparator comparator)
           
 void setCssClass(java.lang.String newValue)
           
 void setDecorator(Decorator decorator)
           Sets the decorator.
 void setDoubleClickActionCommand(boolean b)
           
 void setFocused(boolean focused)
           Sets the input focus to this component.
 void setFont(Font newValue)
          Sets the font of the component.
 void setForeground(Color foreground)
           Sets the foregound color (text in the listbox) of this listbox.
 void setInvalidMessage(java.lang.String invalidMessage)
           Sets the message key that is shown when the component is marked as invalid.
 void setInvalidMessageKey(java.lang.String s)
          Deprecated.  
 void setLabelProperty(java.lang.String labelProperty)
           Sets the property (path), relative to the individual beans in the list ( setList(List)) that is shown to the user in the listbox.
 void setList(java.util.List list)
           Sets the list of java beans the user can select from.
 void setMultiSelect(boolean allowMultiSelect)
           Sets whether or not the listbox allows multiple items to be selected.
 void setNullLabel(java.lang.String nullLabel)
           Sets the label, corresponding to the data binding target value null.
 void setReadOnly(boolean readOnly)
           Mark this component as read-only.
 void setRequired(boolean required)
           Determine if the editor is required to be filled in.
 void setSelectedIndex(int i)
           Sets the index that is selected.
 void setSelectedLabels(java.lang.String labels)
           
 void setToolTipProperty(java.lang.String toolTipProperty)
           Sets the tooltip indirectly by specifying a property path.
 void setToolTipText(java.lang.String text)
           Sets the tooltip that appears when the user hoovers over this component.
 void setVisibleRowCount(int i)
           Sets the number of items that are shown in the listbox at once.
 void setWidth(int width)
           
 void setWidthUnits(int widthUnits)
           
 void valueChanged(ListSelectionEvent arg0)
           Used internally.
 
Methods inherited from class net.sf.jzeno.echo.components.CustomComponent
addValidator, fireActionEvent, fireActionEvent, fireActionEvent, getBean, getBeanClass, getNullObject, getProperty, getValidationErrors, getValidators, getValue, isBound, isMarkedInvalid, isRequired, isValid, markInvalid, markValid, preRender, removeValidator, setBean, setBeanClass, setNullObject, setProperty, setValue, traceValue, validate
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, applyStyle, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setClientId, setEnabled, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jzeno.echo.databinding.PropertyComponent
addValidator, getBean, getBeanClass, getProperty, getValidationErrors, getValidators, getValue, isMarkedInvalid, isRequired, isValid, markInvalid, markValid, preRender, removeValidator, setBean, setBeanClass, setProperty, setValue
 

Field Detail

PIXEL_UNITS

public static final int PIXEL_UNITS
See Also:
Constant Field Values

PERCENT_UNITS

public static final int PERCENT_UNITS
See Also:
Constant Field Values

cssClass

public java.lang.String cssClass
Constructor Detail

DynaListBox

public DynaListBox()

Creates an unbound component.


DynaListBox

public DynaListBox(java.lang.Class beanClass,
                   java.lang.String propertyName,
                   java.lang.String constructionHints)

Creates a databound listbox. For the type of property you should bind to see the class documentation above. (DynaListBox)

Method Detail

valueChanged

public void valueChanged(ListSelectionEvent arg0)

Used internally.

Specified by:
valueChanged in interface ListSelectionListener
Parameters:
arg0 - An event describing the change.

rebind

public void rebind()
Description copied from interface: RebindableComponent

This operation causes the component to reset it's content to that of the domain model.

Specified by:
rebind in interface RebindableComponent
Overrides:
rebind in class CustomComponent

getList

public java.util.List getList()

Gets the list of java beans the user can select from.

Specified by:
getList in interface ListBoxInterface

setList

public void setList(java.util.List list)

Sets the list of java beans the user can select from.

Specified by:
setList in interface ListBoxInterface

getLabelProperty

public java.lang.String getLabelProperty()

Gets the property (path), used to show the java beans in the list, on the screen. Also see setLabelProperty(String).


setLabelProperty

public void setLabelProperty(java.lang.String labelProperty)

Sets the property (path), relative to the individual beans in the list ( setList(List)) that is shown to the user in the listbox.


getNullLabel

public java.lang.String getNullLabel()

Gets the label, corresponding to the data binding target value null. Also see setNullLabel(String).


setNullLabel

public void setNullLabel(java.lang.String nullLabel)

Sets the label, corresponding to the data binding target value null. If the user selects this label (which will appear at the top of the list), the value null will be written to the data binding target. If the data binding target is null this label will be selected on the screen. If you don't want a selection corresponding to null, set this property to null (this is also the default).


getToolTipProperty

public java.lang.String getToolTipProperty()

Gets the tooltip indirectly by specifying a property path.


setToolTipProperty

public void setToolTipProperty(java.lang.String toolTipProperty)

Sets the tooltip indirectly by specifying a property path.


getSelectedItem

public java.lang.Object getSelectedItem()


getDecorator

public Decorator getDecorator()
Description copied from class: CustomComponent
Implementation of RebindableComponent

Specified by:
getDecorator in interface ListBoxInterface
Specified by:
getDecorator in interface PropertyComponent
Overrides:
getDecorator in class CustomComponent

setDecorator

public void setDecorator(Decorator decorator)
Description copied from interface: PropertyComponent

Sets the decorator.

Specified by:
setDecorator in interface ListBoxInterface
Specified by:
setDecorator in interface PropertyComponent
Overrides:
setDecorator in class CustomComponent

getInvalidMessage

public java.lang.String getInvalidMessage()

Gets the message key that is added to the screen, when the component is marked as invalid. Also see setInvalidMessage(String).

Specified by:
getInvalidMessage in interface ListBoxInterface

getInvalidMessageKey

public java.lang.String getInvalidMessageKey()
Deprecated. 


setInvalidMessage

public void setInvalidMessage(java.lang.String invalidMessage)

Sets the message key that is shown when the component is marked as invalid. Typically the component is marked invalid when you call EchoSupport.doValidationRecursively(Component) in your code. The value specified for this property is translated through the i18n support in jZeno (i18n.properties).

Specified by:
setInvalidMessage in interface ListBoxInterface

setInvalidMessageKey

public void setInvalidMessageKey(java.lang.String s)
Deprecated. 


isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface PropertyComponent
Overrides:
isReadOnly in class CustomComponent

setReadOnly

public void setReadOnly(boolean readOnly)
Description copied from interface: PropertyComponent

Mark this component as read-only.

Specified by:
setReadOnly in interface PropertyComponent
Overrides:
setReadOnly in class CustomComponent

contentsChanged

public void contentsChanged(ListDataEvent arg0)

Used internally.

Specified by:
contentsChanged in interface ListDataListener
Parameters:
arg0 - The ListDataEvent describing the update.

intervalAdded

public void intervalAdded(ListDataEvent arg0)

Used internally.

Specified by:
intervalAdded in interface ListDataListener
Parameters:
arg0 - The ListDataEvent describing the update.

intervalRemoved

public void intervalRemoved(ListDataEvent arg0)

Used internally.

Specified by:
intervalRemoved in interface ListDataListener
Parameters:
arg0 - The ListDataEvent describing the update.

isMultiSelect

public boolean isMultiSelect()

Gets whether or not the listbox allows multiple items to be selected.

Specified by:
isMultiSelect in interface ListBoxInterface

setMultiSelect

public void setMultiSelect(boolean allowMultiSelect)

Sets whether or not the listbox allows multiple items to be selected.

Specified by:
setMultiSelect in interface ListBoxInterface

setVisibleRowCount

public void setVisibleRowCount(int i)

Sets the number of items that are shown in the listbox at once. If there are more items in the list of java beans than this property, the user will have to use the scroll bars to view the extra items.


getVisibleRowCount

public int getVisibleRowCount()

Gets the number of items that are shown in the listbox at once. See also setVisibleRowCount(int).


getModel

public ListModel getModel()

Gets the model that is used by this listbox. This will be an instance of type BoundListModel.


setSelectedIndex

public void setSelectedIndex(int i)

Sets the index that is selected. Useful if you are using the listbox without data binding. Otherwise you could just modify the data binding target property.


getSelectedIndex

public int getSelectedIndex()

Gets the index that is selected.


setToolTipText

public void setToolTipText(java.lang.String text)

Sets the tooltip that appears when the user hoovers over this component.


getToolTipText

public java.lang.String getToolTipText()

Gets the tooltip that appears when the user hoovers over this component.


clearSelection

public void clearSelection()

Clears any selection on the component.

Specified by:
clearSelection in interface ListBoxInterface

getSelectedValue

public java.lang.Object getSelectedValue()
Deprecated. 

Gets the javabean that is currently selected.


setActionCommand

public void setActionCommand(java.lang.String command)

Sets the dynamic event handler that will be triggered when a selection is made in the listbox. If you don't want a roundtrip when a selection is made, set this property to null (this is also the default).

Specified by:
setActionCommand in interface EventSource
Overrides:
setActionCommand in class CustomComponent

getActionCommand

public java.lang.String getActionCommand()
Specified by:
getActionCommand in interface EventSource
Overrides:
getActionCommand in class CustomComponent

actionPerformed

public void actionPerformed(ActionEvent e)

Gets the dynamic event handler that will be triggered when a selection is made in the listbox.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The event describing the action.

getBackground

public Color getBackground()

Gets the background color of this listbox.

Specified by:
getBackground in interface Component
Overrides:
getBackground in class AbstractComponent
Returns:
The background color of the component.

setBackground

public void setBackground(Color background)

Sets the background color of this listbox.

Specified by:
setBackground in interface Component
Overrides:
setBackground in class AbstractComponent
Parameters:
background - The new background color of the component.

getForeground

public Color getForeground()

Gets the foregound color (text in the listbox) of this listbox.

Specified by:
getForeground in interface Component
Overrides:
getForeground in class AbstractComponent
Returns:
The foreground of the component.

setForeground

public void setForeground(Color foreground)

Sets the foregound color (text in the listbox) of this listbox.

Specified by:
setForeground in interface Component
Overrides:
setForeground in class AbstractComponent
Parameters:
foreground - The new foreground color of the component.

setRequired

public void setRequired(boolean required)
Description copied from interface: PropertyComponent

Determine if the editor is required to be filled in.

Specified by:
setRequired in interface PropertyComponent
Overrides:
setRequired in class CustomComponent

setFocused

public void setFocused(boolean focused)

Sets the input focus to this component.

Specified by:
setFocused in interface ListBoxInterface
Specified by:
setFocused in interface Component
Overrides:
setFocused in class AbstractComponent
Parameters:
focused - True if the component is to be focused.

setComparator

public void setComparator(java.util.Comparator comparator)
Specified by:
setComparator in interface ListBoxInterface

getComparator

public java.util.Comparator getComparator()
Specified by:
getComparator in interface ListBoxInterface

setWidth

public void setWidth(int width)
Specified by:
setWidth in interface ListBoxInterface

getWidth

public int getWidth()
Specified by:
getWidth in interface ListBoxInterface

setWidthUnits

public void setWidthUnits(int widthUnits)
Specified by:
setWidthUnits in interface ListBoxInterface

getWidthUnits

public int getWidthUnits()
Specified by:
getWidthUnits in interface ListBoxInterface

setDoubleClickActionCommand

public void setDoubleClickActionCommand(boolean b)

isDoubleClickActionCommand

public boolean isDoubleClickActionCommand()

applyContext

public void applyContext()
Specified by:
applyContext in interface Precreation

getFont

public Font getFont()
Description copied from interface: Component
Returns the font.

Specified by:
getFont in interface ListBoxInterface
Specified by:
getFont in interface Component
Overrides:
getFont in class AbstractComponent
Returns:
The font of the component.

setFont

public void setFont(Font newValue)
Description copied from interface: Component
Sets the font of the component.

Specified by:
setFont in interface ListBoxInterface
Specified by:
setFont in interface Component
Overrides:
setFont in class AbstractComponent
Parameters:
newValue - The new font of the component.

setAsync

public void setAsync(boolean async)

isAsync

public boolean isAsync()

changed

public void changed(java.util.Collection collection)
Specified by:
changed in interface CollectionChangeListener

getSelectedLabels

public java.lang.String getSelectedLabels()
Returns the label that the user selected. Useful for validation in scripts.

Returns:

setSelectedLabels

public void setSelectedLabels(java.lang.String labels)

getCssClass

public java.lang.String getCssClass()

setCssClass

public void setCssClass(java.lang.String newValue)