com.sun.rave.web.ui.component
Class ListSelector

java.lang.Object
  extended byjavax.faces.component.UIComponent
      extended byjavax.faces.component.UIComponentBase
          extended byjavax.faces.component.UIOutput
              extended byjavax.faces.component.UIInput
                  extended bycom.sun.rave.web.ui.component.SelectorBase
                      extended bycom.sun.rave.web.ui.component.Selector
                          extended bycom.sun.rave.web.ui.component.ListSelectorBase
                              extended bycom.sun.rave.web.ui.component.ListSelector
All Implemented Interfaces:
ComplexComponent, javax.faces.component.EditableValueHolder, ListManager, SelectorManager, javax.faces.component.StateHolder, javax.faces.component.ValueHolder
Direct Known Subclasses:
AddRemoveBase, DropDownBase, ListboxBase

public class ListSelector
extends ListSelectorBase
implements ListManager

Author:
avk

Field Summary
static java.lang.String LIST_ID
           
protected  java.util.ArrayList listItems
           
static java.lang.String VALUE_ID
           
 
Fields inherited from class com.sun.rave.web.ui.component.Selector
valueTypeEvaluator
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID
 
Constructor Summary
ListSelector()
          Creates a new instance of ListSelector
 
Method Summary
 void checkSelectionModel(javax.faces.context.FacesContext context)
          Check that this component has a valuebinding that matches the value of the "multiple" attribute.
protected  ListItem createListItem(Option si)
           
 javax.faces.component.UIComponent getLabelComponent()
           
 java.util.Iterator getListItems()
          Retrieve an Iterator of ListSelector.ListItem, to be used when evaluting the list items.
 java.util.Iterator getListItems(javax.faces.context.FacesContext context, boolean rulerAtEnd)
          Retrieve an Iterator of ListSelector.ListItem, to be used by the renderer.
protected  Option[] getOptions()
          Processes the component's SelectItems.
 java.lang.String getPrimaryElementID(javax.faces.context.FacesContext context)
          Implement this method so that it returns the DOM ID of the HTML element which should receive focus when the component receives focus, and to which a component label should apply.
 javax.faces.component.UIComponent getReadOnlyValueComponent()
          Returns a UIComponent used to display the readonly value for this component
 int getSeparatorLength()
          This method resets the options.
 java.lang.String getValueAsReadOnly(javax.faces.context.FacesContext context, java.lang.String separator)
           
 java.lang.String[] getValueAsStringArray(javax.faces.context.FacesContext context)
          Get the value (the object representing the selection(s)) of this component as a String array.
 boolean mainListSubmits()
           
protected  void markSelectedListItems(java.util.List list, boolean processed)
          Marks options corresponding to objects listed as values of this components as selected.
protected  void processOptions(Option[] options)
           
protected  void processSelections()
          Retrieve the current selections and compare them with the list items.
 
Methods inherited from class com.sun.rave.web.ui.component.ListSelectorBase
getFamily, getRows, isLabelOnTop, isSeparators, isVisible, restoreState, saveState, setLabelOnTop, setRows, setSeparators, setVisible
 
Methods inherited from class com.sun.rave.web.ui.component.Selector
compareValues, getConvertedValue, getLabelLevel, getRendersChildren, getValueAsReadOnly, isMultiple, setMultiple, setSelected, toString
 
Methods inherited from class com.sun.rave.web.ui.component.SelectorBase
getItems, getLabel, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getSelected, getStyle, getStyleClass, getTabIndex, getToolTip, getValueBinding, isDisabled, isReadOnly, setDisabled, setItems, setLabel, setLabelLevel, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setReadOnly, setStyle, setStyleClass, setTabIndex, setToolTip, setValueBinding
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, broadcast, decode, getSubmittedValue, getValidator, getValidators, getValueChangeListener, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, setImmediate, setLocalValueSet, setRequired, setSubmittedValue, setValid, setValidator, setValue, setValueChangeListener, updateModel, validate, validateValue
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, getValue, setConverter
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sun.rave.web.ui.component.ListManager
getRows, getToolTip, isVisible
 
Methods inherited from interface javax.faces.component.EditableValueHolder
addValidator, addValueChangeListener, getSubmittedValue, getValidator, getValidators, getValueChangeListener, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, removeValidator, removeValueChangeListener, setImmediate, setLocalValueSet, setRequired, setSubmittedValue, setValid, setValidator, setValueChangeListener
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue, setConverter, setValue
 
Methods inherited from interface com.sun.rave.web.ui.component.SelectorManager
getClientId, getOnChange, getStyle, getStyleClass, getTabIndex, isDisabled, isMultiple, isReadOnly
 

Field Detail

listItems

protected java.util.ArrayList listItems

VALUE_ID

public static final java.lang.String VALUE_ID
See Also:
Constant Field Values

LIST_ID

public static final java.lang.String LIST_ID
See Also:
Constant Field Values
Constructor Detail

ListSelector

public ListSelector()
Creates a new instance of ListSelector

Method Detail

checkSelectionModel

public void checkSelectionModel(javax.faces.context.FacesContext context)
Check that this component has a valuebinding that matches the value of the "multiple" attribute.

Parameters:
context - The FacesContext of the request

getListItems

public java.util.Iterator getListItems(javax.faces.context.FacesContext context,
                                       boolean rulerAtEnd)
                                throws javax.faces.FacesException
Retrieve an Iterator of ListSelector.ListItem, to be used by the renderer.

Specified by:
getListItems in interface ListManager
Parameters:
rulerAtEnd - If this attribute is set to true, the iterator will contain, as the last item, a disabled list option with a blank label whose sole function is to guarantee that the list stays the same size
Returns:
an Iterator over ListItem.
Throws:
javax.faces.FacesException

getListItems

public java.util.Iterator getListItems()
                                throws javax.faces.FacesException
Retrieve an Iterator of ListSelector.ListItem, to be used when evaluting the list items. If the list items are needed by the renderer, use getListItems(context, rulerAtEnd) instead.

Returns:
an Iterator over ListItem.
Throws:
javax.faces.FacesException

getSeparatorLength

public int getSeparatorLength()
This method resets the options. Use this only if you need to add or remove options after the component has been rendered once. public void resetOptions() { listItems = null; }


getOptions

protected Option[] getOptions()
Processes the component's SelectItems. Constructs an ArrayList of Selector.Options.


processOptions

protected void processOptions(Option[] options)

processSelections

protected void processSelections()
Retrieve the current selections and compare them with the list items.


markSelectedListItems

protected void markSelectedListItems(java.util.List list,
                                     boolean processed)
Marks options corresponding to objects listed as values of this components as selected.

Parameters:
list - A list representation of the selected values
processed - If true, compare the values object by object (this is done if we compare the value of the object with with the list items). If false, perform a string comparison of the string representation of the submitted value of the component with the string representation of the value from the list items (this is done if we compare the submitted values with the list items).

createListItem

protected ListItem createListItem(Option si)

getLabelComponent

public javax.faces.component.UIComponent getLabelComponent()

getReadOnlyValueComponent

public javax.faces.component.UIComponent getReadOnlyValueComponent()
Description copied from interface: ListManager
Returns a UIComponent used to display the readonly value for this component

Specified by:
getReadOnlyValueComponent in interface ListManager
Returns:
a UIComponent used to display the readonly value for this component

getValueAsStringArray

public java.lang.String[] getValueAsStringArray(javax.faces.context.FacesContext context)
Get the value (the object representing the selection(s)) of this component as a String array.

Specified by:
getValueAsStringArray in interface ListManager
Parameters:
context - The FacesContext of the request
Returns:
A string representation of the value

getPrimaryElementID

public java.lang.String getPrimaryElementID(javax.faces.context.FacesContext context)
Description copied from interface: ComplexComponent
Implement this method so that it returns the DOM ID of the HTML element which should receive focus when the component receives focus, and to which a component label should apply. Usually, this is the first element that accepts input.

Specified by:
getPrimaryElementID in interface ComplexComponent
Parameters:
context - The FacesContext for the request
Returns:
The client id, also the JavaScript element id

getValueAsReadOnly

public java.lang.String getValueAsReadOnly(javax.faces.context.FacesContext context,
                                           java.lang.String separator)

mainListSubmits

public boolean mainListSubmits()
Specified by:
mainListSubmits in interface ListManager