Decision Center API

ilog.webui.dhtml.components
Class IlxWComboBox

java.lang.Object
  extended by ilog.webui.dhtml.IlxWContainer
      extended by ilog.webui.dhtml.IlxWComponent
          extended by ilog.webui.dhtml.components.IlxWLabelWrapper
              extended by ilog.webui.dhtml.components.IlxWComboBox
All Implemented Interfaces:
ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, ilog.webui.dhtml.IlxWJSObject, ActionListener, ItemSelectable, Serializable, EventListener, ListDataListener

public class IlxWComboBox
extends ilog.webui.dhtml.components.IlxWLabelWrapper
implements ListDataListener, ItemSelectable, ActionListener

A combo box component.

The combo box component relies on a model, instance of javax.swing.ComboBoxModel. It may be rendered in several modes, determined by the value of the "mode" CSS style. Possible values for the mode style are:

If no mode is set, the component always first tries to render in system mode. To set the current mode, you can either write a CSS style sheet:
 ComboBox
 {
   mode: arrow;
 }
 
... or dynamically set the style on the object:
 myComboBox.getStyle().set("mode", "arrow");
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ilog.webui.dhtml.IlxWComponent
IlxWComponent.DynamicStyleMap
 
Field Summary
static String ACTION_PROPERTY
          The action bound property name.
protected  String actionCommand
           
static String EDITABLE_PROPERTY
          The editable bound property name.
protected  IlxWComboBoxEditor editor
           
static String EDITOR_PROPERTY
          The editor bound property name.
static String ENABLED_PROPERTY
          The enabled bound property name.
protected  boolean isEditable
           
protected  ComboBoxModel model
           
static String MODEL_PROPERTY
          The model bound property name.
protected  IlxWListCellRenderer renderer
           
static String RENDERER_PROPERTY
          The renderer bound property name.
protected  ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI ui
          Access to allow another UI to the combo box (JSF)
 
Fields inherited from class ilog.webui.dhtml.components.IlxWLabelWrapper
cssDescriptor, label
 
Fields inherited from class ilog.webui.dhtml.IlxWContainer
listenerList
 
Constructor Summary
IlxWComboBox()
          Creates an IlxWComboBox with a default data model.
IlxWComboBox(ComboBoxModel aModel)
          Creates an IlxWComboBox that takes its items from an existing ComboBoxModel.
IlxWComboBox(Object[] items)
          Creates an IlxWComboBox that contains the elements in the specified array.
IlxWComboBox(Vector items)
          Creates an IlxWComboBox that contains the elements in the specified Vector.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addActionListener(ActionListener l)
          Adds an action listener.
 void addItemListener(ItemListener listener)
          Adds an item listener.
 void configureEditor(IlxWComboBoxEditor anEditor, Object anItem)
          Initializes the editor with the specified item.
 void contentsChanged(ListDataEvent e)
           
protected  void fireActionEvent()
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireItemStateChanged(ItemEvent e)
          Notify all listeners that have registered interest for notification on this event type.
 IlxWAction getAction()
          Gets the action that will be called when the user selects an item in the combo box.
 String getActionCommand()
          Returns the action command that is included in the event sent to action listeners.
 ActionListener[] getActionListeners()
           
 IlxWComboBoxEditor getEditor()
          Returns the editor used to render and edit the selected item in the IlxWComboBox field.
 Object getItemAt(int index)
          Returns the list item at the specified index.
 int getItemCount()
          Returns the number of items in the list.
 ItemListener[] getItemListeners()
           
 ComboBoxModel getModel()
          Returns the data model currently used by the IlxWComboBox.
 String getOnChangeJSAction()
           
 IlxWListCellRenderer getRenderer()
          Returns the renderer used to display the selected item in the IlxWComboBox field.
 int getSelectedIndex()
          Returns the index of the currently selected item in the list.
 Object getSelectedItem()
          Returns the currently selected item.
 Object[] getSelectedObjects()
          Returns an array containing the selected item.
protected  ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI()
           
protected  ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI(IlxWPort port)
           
protected  IlxWCSSRuleset getUserAgentRules()
          Gets the "user-agent" CSS rules.
 void intervalAdded(ListDataEvent e)
           
 void intervalRemoved(ListDataEvent e)
           
 boolean isEditable()
          Returns True if the IlxWComboBox is editable.
 boolean isEnabled()
          Determines whether this component is enabled.
 void notifyDependencies(IlxWPort port)
           
protected  void printComponent(IlxWPort port)
          Prints the HTML code that will display the graphical representation of this component.
 void removeActionListener(ActionListener l)
          Removes an action listener.
 void removeItemListener(ItemListener listener)
          Removes an item listener.
protected  void selectedItemChanged()
          This method is called when the selected item changes.
 void setAction(IlxWAction action)
          Sets the action that will be called when the user selects an item in the combo box.
 void setActionCommand(String aCommand)
          Sets the action command that should be included in the event sent to action listeners.
 void setEditable(boolean aFlag)
          Determines whether the IlxWComboBox field is editable.
 void setEditor(IlxWComboBoxEditor editor)
          Sets the editor used to paint and edit the selected item in the IlxWComboBox field.
 void setEnabled(boolean b)
          Enables the combo box so that items can be selected.
 void setModel(ComboBoxModel model)
          Sets the data model that the IlxWComboBox uses to obtain the list of items.
 void setOnChangeJSAction(String onChangeAction)
           
 void setRenderer(IlxWListCellRenderer renderer)
          Sets the renderer that paints the item selected from the list in the IlxWComboBox field.
 void setSelectedIndex(int index)
          Selects the item at index anIndex.
 void setSelectedItem(Object anObject)
          Sets the selected item in the IlxWComboBox by specifying the object in the list.
 void update(Element elt)
           
 
Methods inherited from class ilog.webui.dhtml.components.IlxWLabelWrapper
getCSSModel, getIconPath, getIcoPath, getLabel, getText, setIconPath, setText
 
Methods inherited from class ilog.webui.dhtml.IlxWComponent
addPropertyChangeListener, addPropertyChangeListener, detach, doPrint, firePropertyChange, firePropertyChange, getName, getRealHtmlTagName, getStyle, invalidate, isInvalidated, print, removePropertyChangeListener, removePropertyChangeListener, setName, validate
 
Methods inherited from class ilog.webui.dhtml.IlxWContainer
add, add, getAttribute, getAttributeNames, getComponent, getComponentCount, getComponentNamed, getComponents, getManager, getParent, indexOf, isAncestorOf, remove, remove, removeAll, removeAttribute, setAttribute, setAuthorRules, setFinalizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODEL_PROPERTY

public static final String MODEL_PROPERTY
The model bound property name.

See Also:
Constant Field Values

EDITOR_PROPERTY

public static final String EDITOR_PROPERTY
The editor bound property name.

See Also:
Constant Field Values

EDITABLE_PROPERTY

public static final String EDITABLE_PROPERTY
The editable bound property name.

See Also:
Constant Field Values

ENABLED_PROPERTY

public static final String ENABLED_PROPERTY
The enabled bound property name.

See Also:
Constant Field Values

ACTION_PROPERTY

public static final String ACTION_PROPERTY
The action bound property name.

See Also:
Constant Field Values

RENDERER_PROPERTY

public static final String RENDERER_PROPERTY
The renderer bound property name.

See Also:
Constant Field Values

model

protected ComboBoxModel model

renderer

protected IlxWListCellRenderer renderer

editor

protected IlxWComboBoxEditor editor

isEditable

protected boolean isEditable

actionCommand

protected String actionCommand

ui

protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI ui
Access to allow another UI to the combo box (JSF)

Constructor Detail

IlxWComboBox

public IlxWComboBox(ComboBoxModel aModel)
Creates an IlxWComboBox that takes its items from an existing ComboBoxModel.

Parameters:
aModel - The ComboBoxModel that provides the displayed list of items.

IlxWComboBox

public IlxWComboBox(Object[] items)
Creates an IlxWComboBox that contains the elements in the specified array.


IlxWComboBox

public IlxWComboBox(Vector items)
Creates an IlxWComboBox that contains the elements in the specified Vector.


IlxWComboBox

public IlxWComboBox()
Creates an IlxWComboBox with a default data model. Use addItem to add items.

Method Detail

setModel

public void setModel(ComboBoxModel model)
Sets the data model that the IlxWComboBox uses to obtain the list of items.

Parameters:
model - The combo box model that provides the displayed list of items.

getModel

public ComboBoxModel getModel()
Returns the data model currently used by the IlxWComboBox.

Returns:
The combo box model that provides the displayed list of items.

setEditable

public void setEditable(boolean aFlag)
Determines whether the IlxWComboBox field is editable.

An editable IlxWComboBox allows the user to type into the field or select an item from the list to initialize the field, after which it can be edited.

A non editable IlxWComboBox displays the selected item in the field, but the selection cannot be modified.

Parameters:
aFlag - A boolean value, where true indicates that the field is editable.

isEditable

public boolean isEditable()
Returns True if the IlxWComboBox is editable.

Returns:
true if the combo box can be edited; false otherwise.

setRenderer

public void setRenderer(IlxWListCellRenderer renderer)
Sets the renderer that paints the item selected from the list in the IlxWComboBox field.

The renderer is used if the IlxWComboBox is not editable, otherwise the editor is used to render and edit the selected item.

The default renderer displays a string, obtained by calling the selected object's toString method. Other renderers can handle graphic images and composite items.

To display the selected item, aRenderer.getListCellRendererComponent is called, passing the list object and an index of -1.

Parameters:
renderer - The ListCellRenderer that displays the selected item.
See Also:
setEditor(ilog.webui.dhtml.components.IlxWComboBoxEditor)

getRenderer

public IlxWListCellRenderer getRenderer()
Returns the renderer used to display the selected item in the IlxWComboBox field.

Returns:
The list cell renderer that displays the selected item.

setEditor

public void setEditor(IlxWComboBoxEditor editor)
Sets the editor used to paint and edit the selected item in the IlxWComboBox field.

The editor is used only if the receiving IlxWComboBox is editable. If not editable, the combo box uses the renderer to render the selected item.

Parameters:
editor - The IlxWComboBoxEditor that displays the selected item.
See Also:
setRenderer(ilog.webui.dhtml.components.IlxWListCellRenderer)

getEditor

public IlxWComboBoxEditor getEditor()
Returns the editor used to render and edit the selected item in the IlxWComboBox field.

Returns:
The combo box editor that displays the selected item.

configureEditor

public void configureEditor(IlxWComboBoxEditor anEditor,
                            Object anItem)
Initializes the editor with the specified item.

Parameters:
anEditor - The IlxWComboBoxEditor that displays the list item in the combo box field and allows it to be edited.
anItem - The object to display and edit in the field.

setSelectedItem

public void setSelectedItem(Object anObject)
Sets the selected item in the IlxWComboBox by specifying the object in the list.

If anObject is in the list, the list displays with anObject selected. If the object does not exist in the list, the default data model selects the first item in the list.

Parameters:
anObject - The list object to select.

getSelectedItem

public Object getSelectedItem()
Returns the currently selected item.

Returns:
The currently selected object in the data model.

setSelectedIndex

public void setSelectedIndex(int index)
Selects the item at index anIndex.

Parameters:
index - An int specifying the list item to select, where 0 specifies the first item in the list.

getSelectedIndex

public int getSelectedIndex()
Returns the index of the currently selected item in the list.

The result is not always defined if the IlxWComboBox box allows selected items that are not in the list. Returns -1 if there is no selected item or if the user specified an item which is not in the list.

Returns:
An int specifying the list item that is currently selected 0 specifies the first item in the list, -1 indicates that no item is selected or that the currently selected item is not in the list.

addItemListener

public void addItemListener(ItemListener listener)
Adds an item listener.

aListener will receive an event when the selected item changes.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
listener - The item listener that is to be notified.

removeItemListener

public void removeItemListener(ItemListener listener)
Removes an item listener.

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
listener - The item listener to remove.

addActionListener

public void addActionListener(ActionListener l)
Adds an action listener.

The listener will receive an action event the user finishes making a selection.

Parameters:
l - The action listener that is to be notified.

removeActionListener

public void removeActionListener(ActionListener l)
Removes an action listener.

Parameters:
l - The action listener to remove.

setActionCommand

public void setActionCommand(String aCommand)
Sets the action command that should be included in the event sent to action listeners.

Parameters:
aCommand - A string containing the "command" that is sent to action listeners. The same listener can then do different things depending on the command it receives.

getActionCommand

public String getActionCommand()
Returns the action command that is included in the event sent to action listeners.

Returns:
the string containing the command that is sent to action listeners. This command is an arbitrary character string.

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Notify all listeners that have registered interest for notification on this event type.

See Also:
EventListenerList

getItemListeners

public ItemListener[] getItemListeners()

fireActionEvent

protected void fireActionEvent()
Notify all listeners that have registered interest for notification on this event type.


getActionListeners

public ActionListener[] getActionListeners()

selectedItemChanged

protected void selectedItemChanged()
This method is called when the selected item changes.

Its default implementation notifies the item listeners.


getSelectedObjects

public Object[] getSelectedObjects()
Returns an array containing the selected item.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
An array of objects containing one element -- the selected item.

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

getUI

protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI(IlxWPort port)
Parameters:
port - The current port.
Returns:
the UI of the combo box.

getUI

protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI()
Returns:
the UI of the combo box.

intervalAdded

public void intervalAdded(ListDataEvent e)
Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Specified by:
intervalRemoved in interface ListDataListener

contentsChanged

public void contentsChanged(ListDataEvent e)
Specified by:
contentsChanged in interface ListDataListener

setEnabled

public void setEnabled(boolean b)
Enables the combo box so that items can be selected.

When the combo box is disabled, items cannot be selected and values cannot be typed into its field (if it is editable).

Parameters:
b - A boolean value, where true enables the component and false disables it.

isEnabled

public boolean isEnabled()
Determines whether this component is enabled.

Returns:
true if this component is enabled.
See Also:
setEnabled(boolean)

getItemCount

public int getItemCount()
Returns the number of items in the list.

Returns:
an int equal to the number of items in the list.

getItemAt

public Object getItemAt(int index)
Returns the list item at the specified index.

Parameters:
index - An int indicating the list position, where the first item starts at zero.
Returns:
the Object at that list position.

getAction

public IlxWAction getAction()
Gets the action that will be called when the user selects an item in the combo box.

By default, this action is a Java action (IlxWJavaAction) of which the perform method calls setSelectedItem on the combo box.

If the given action is a Java action (IlxWJavaAction), the argument array passed to the perform method is a 1-length array containing the selected item. If the given action is a JS action (IlxWJSAction), the argument array passed when calling the associated function is a 1-length array containing the string representation of the selected item.

Returns:
the action to perform when the user selects an item.
See Also:
setAction(ilog.webui.dhtml.components.IlxWAction)

setAction

public void setAction(IlxWAction action)
Sets the action that will be called when the user selects an item in the combo box.

Parameters:
action - The action to perform when the user selects an item from the list.
See Also:
getAction()

setOnChangeJSAction

public void setOnChangeJSAction(String onChangeAction)

getOnChangeJSAction

public String getOnChangeJSAction()

update

public void update(Element elt)

printComponent

protected void printComponent(IlxWPort port)
                       throws IOException
Description copied from class: IlxWComponent
Prints the HTML code that will display the graphical representation of this component. This method is called by the IlxWComponent.print(ilog.webui.dhtml.IlxWPort) method.

Overrides:
printComponent in class ilog.webui.dhtml.components.IlxWLabelWrapper
Throws:
IOException
Parameters:
port - The port on which the component will be printed.
See Also:
IlxWComponent.print(ilog.webui.dhtml.IlxWPort)

getUserAgentRules

protected IlxWCSSRuleset getUserAgentRules()
Description copied from class: IlxWContainer
Gets the "user-agent" CSS rules.
User agent rules are a set of CSS rules which will apply by default to each instance of this container. They may be completed or overridden by the author rules, set via the setAuthorRules method.

This method returns null by default but is intended to be redefined by subclasses.

Overrides:
getUserAgentRules in class IlxWContainer
Returns:
a CSS ruleset.
See Also:
IlxWContainer.setAuthorRules(ilog.webui.dhtml.IlxWCSSRuleset)

notifyDependencies

public void notifyDependencies(IlxWPort port)
Specified by:
notifyDependencies in interface ilog.webui.dhtml.IlxWDependencyProvider
Overrides:
notifyDependencies in class IlxWComponent

Decision Center API

© Copyright IBM Corp. 1987, 2013