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

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
                                  extended bycom.sun.rave.web.ui.component.AddRemoveBase
                                      extended bycom.sun.rave.web.ui.component.AddRemove
All Implemented Interfaces:
ComplexComponent, javax.faces.component.EditableValueHolder, ListManager, SelectorManager, javax.faces.component.StateHolder, javax.faces.component.ValueHolder

public class AddRemove
extends AddRemoveBase
implements ListManager

Use the AddRemove component when the web application user makes selections from a list and they need to see the currently selected items displayed together, and/or they need to reorder the selected items.

Author:
avk

Field Summary
static java.lang.String ADD_BUTTON_FACET
          The facet name of the add button
static java.lang.String ADD_BUTTON_ID
          The component id for the ADD button
static java.lang.String ADD_FUNCTION
          Name of the JavaScript function which is responsible for adding elements from the availble list to the selected list
static java.lang.String ADDALL_BUTTON_FACET
          The facet name of the Add All button
static java.lang.String ADDALL_BUTTON_ID
          The component id for the ADD ALL button
static java.lang.String ADDALL_FUNCTION
          Name of the JavaScript function which is responsible for selecting all the available items
static java.lang.String AVAILABLE_ID
          The id of the label component that functions as the label above the available list
static java.lang.String AVAILABLE_LABEL_FACET
          The facet name of the label over the "Available" list
static java.lang.String AVAILABLE_LABEL_ID
          The component ID for the items list
static java.lang.String AVAILABLE_ONCHANGE_FUNCTION
          Name of the JavaScript function that handles changes on the available list
static java.lang.String FOOTER_FACET
          Facet name for the footer facet
static java.lang.String HEADER_FACET
          Facet name for the header facet
static java.lang.String HEADER_ID
          The facet name of the header (component label)
static java.lang.String JAVASCRIPT_PREFIX
          Represents the "javascript:" printed at the start of javascript event handler code
static java.lang.String JSOBJECT
          The name of the component attribute that stores the name of the JavaScript object that organizes the JavsSCript functions for the component
static java.lang.String MOVEDOWN_BUTTON_FACET
          The facet name of the "Move Down" button
static java.lang.String MOVEDOWN_BUTTON_ID
          The component ID for the move down button
static java.lang.String MOVEDOWN_FUNCTION
          Name of the JavaScript function which moves elements down
static java.lang.String MOVEUP_BUTTON_FACET
          The facet name of the "Move Up" button
static java.lang.String MOVEUP_BUTTON_ID
          The component ID for the move up button
static java.lang.String MOVEUP_FUNCTION
          Name of the JavaScript function which moves elements up
static java.lang.String MULTIPLEADDITIONS_FUNCTION
          The name of the JavaScript function used to hook up the correct add and remove functions when the component allows items to be added to the selected items list more than once
static java.lang.String REMOVE_BUTTON_FACET
          The facet name of the remove button
static java.lang.String REMOVE_BUTTON_ID
          The component ID for the remove button
static java.lang.String REMOVE_FUNCTION
          Name of the JavaScript function which removes items from the seleted list
static java.lang.String REMOVEALL_BUTTON_FACET
          The facet name of the "Remove All" button
static java.lang.String REMOVEALL_BUTTON_ID
          The component ID for the remove all button
static java.lang.String REMOVEALL_FUNCTION
          Name of the JavaScript function which removes all the items from the seleted list
static java.lang.String RETURN
          String representing "return false" printed at the end of the javascript event handlers
static java.lang.String SELECTED_ID
          The ID of the component that functions as the label above the "Selected" list
static java.lang.String SELECTED_LABEL_FACET
          The facet name of the label over the "Selected" list
static java.lang.String SELECTED_LABEL_ID
          The component ID for the selected list
static java.lang.String SELECTED_ONCHANGE_FUNCTION
          Name of the JavaScript function which handles changes to the selected list
static java.lang.String SEPARATOR_VALUE
          The string used as a separator between the selected values
static java.lang.String SPACER_STRING
           
static java.lang.String UPDATEBUTTONS_FUNCTION
          Name of the JavaScript function that updates the buttons
 
Fields inherited from class com.sun.rave.web.ui.component.ListSelector
LIST_ID, listItems, 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
AddRemove()
          Constructor for the AddRemove component
 
Method Summary
 javax.faces.component.UIComponent getAddAllButtonComponent()
          Get or create the ADD button.
 javax.faces.component.UIComponent getAddButtonComponent(javax.faces.context.FacesContext context)
          Get or create the ADD button.
 java.lang.String getAllValues()
          This function returns a String consisting of the String representation of the values of all the available Options, separated by the separator String (see getSeparator())
 javax.faces.component.UIComponent getAvailableLabelComponent()
          Gets or creates a component for the "available" list label.
 javax.faces.component.UIComponent getHeaderComponent()
          Gets or creates a component for the "component" list label.
 java.util.Iterator getListItems(javax.faces.context.FacesContext context, boolean rulerAtEnd)
          Retrieve an Iterator of ListSelector.ListItem representing the available selections only.
 javax.faces.component.UIComponent getMoveDownButtonComponent()
          Get or create the MOVEDOWN button.
 javax.faces.component.UIComponent getMoveUpButtonComponent()
          Get or create the MOVEUP button.
 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 getRemoveAllButtonComponent()
          Get or create the REMOVE button.
 javax.faces.component.UIComponent getRemoveButtonComponent()
          Get or create the REMOVE button.
 int getRows()
          Get the number of rows to disaplay (the default is 12)
 java.util.Iterator getSelectedItems()
          Returns an iterator over the selected items
 javax.faces.component.UIComponent getSelectedLabelComponent()
          Gets or creates a component for the "selected" list label.
 java.util.Iterator getSelectedListItems()
          Retrieve an Iterator of ListSelector.ListItem representing the selected selections only.
 java.lang.String getSelectedValues()
          This function returns a String consisting of the String representation of the values of the selected Options, separated by the separator String
 java.lang.String getSeparator()
          Get the separator string that is used to separate the selected values on the client.
 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(javax.faces.context.FacesContext context, java.text.Collator collator, java.util.Locale locale, boolean rulerAtEnd)
          Evaluates the list of available Options, creating a ListItem for each one.
 
Methods inherited from class com.sun.rave.web.ui.component.AddRemoveBase
getAvailableItemsLabel, getFamily, getSelectedItemsLabel, getToolTip, isDuplicateSelections, isMoveButtons, isSelectAll, isSorted, isVertical, restoreState, saveState, setAvailableItemsLabel, setDuplicateSelections, setMoveButtons, setSelectAll, setSelectedItemsLabel, setSorted, setToolTip, setVertical
 
Methods inherited from class com.sun.rave.web.ui.component.ListSelector
checkSelectionModel, createListItem, getLabelComponent, getListItems, getOptions, getReadOnlyValueComponent, getSeparatorLength, getValueAsReadOnly, getValueAsStringArray, processOptions, processSelections
 
Methods inherited from class com.sun.rave.web.ui.component.ListSelectorBase
isLabelOnTop, isSeparators, isVisible, 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, 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, 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
getReadOnlyValueComponent, getToolTip, getValueAsStringArray, 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

ADD_BUTTON_ID

public static final java.lang.String ADD_BUTTON_ID
The component id for the ADD button

See Also:
Constant Field Values

ADD_BUTTON_FACET

public static final java.lang.String ADD_BUTTON_FACET
The facet name of the add button

See Also:
Constant Field Values

ADDALL_BUTTON_ID

public static final java.lang.String ADDALL_BUTTON_ID
The component id for the ADD ALL button

See Also:
Constant Field Values

ADDALL_BUTTON_FACET

public static final java.lang.String ADDALL_BUTTON_FACET
The facet name of the Add All button

See Also:
Constant Field Values

REMOVE_BUTTON_ID

public static final java.lang.String REMOVE_BUTTON_ID
The component ID for the remove button

See Also:
Constant Field Values

REMOVE_BUTTON_FACET

public static final java.lang.String REMOVE_BUTTON_FACET
The facet name of the remove button

See Also:
Constant Field Values

REMOVEALL_BUTTON_ID

public static final java.lang.String REMOVEALL_BUTTON_ID
The component ID for the remove all button

See Also:
Constant Field Values

REMOVEALL_BUTTON_FACET

public static final java.lang.String REMOVEALL_BUTTON_FACET
The facet name of the "Remove All" button

See Also:
Constant Field Values

MOVEUP_BUTTON_ID

public static final java.lang.String MOVEUP_BUTTON_ID
The component ID for the move up button

See Also:
Constant Field Values

MOVEUP_BUTTON_FACET

public static final java.lang.String MOVEUP_BUTTON_FACET
The facet name of the "Move Up" button

See Also:
Constant Field Values

MOVEDOWN_BUTTON_ID

public static final java.lang.String MOVEDOWN_BUTTON_ID
The component ID for the move down button

See Also:
Constant Field Values

MOVEDOWN_BUTTON_FACET

public static final java.lang.String MOVEDOWN_BUTTON_FACET
The facet name of the "Move Down" button

See Also:
Constant Field Values

AVAILABLE_LABEL_ID

public static final java.lang.String AVAILABLE_LABEL_ID
The component ID for the items list

See Also:
Constant Field Values

AVAILABLE_LABEL_FACET

public static final java.lang.String AVAILABLE_LABEL_FACET
The facet name of the label over the "Available" list

See Also:
Constant Field Values

SELECTED_LABEL_ID

public static final java.lang.String SELECTED_LABEL_ID
The component ID for the selected list

See Also:
Constant Field Values

SELECTED_LABEL_FACET

public static final java.lang.String SELECTED_LABEL_FACET
The facet name of the label over the "Selected" list

See Also:
Constant Field Values

HEADER_FACET

public static final java.lang.String HEADER_FACET
Facet name for the header facet

See Also:
Constant Field Values

HEADER_ID

public static final java.lang.String HEADER_ID
The facet name of the header (component label)

See Also:
Constant Field Values

FOOTER_FACET

public static final java.lang.String FOOTER_FACET
Facet name for the footer facet

See Also:
Constant Field Values

AVAILABLE_ID

public static final java.lang.String AVAILABLE_ID
The id of the label component that functions as the label above the available list

See Also:
Constant Field Values

SELECTED_ID

public static final java.lang.String SELECTED_ID
The ID of the component that functions as the label above the "Selected" list

See Also:
Constant Field Values

JSOBJECT

public static final java.lang.String JSOBJECT
The name of the component attribute that stores the name of the JavaScript object that organizes the JavsSCript functions for the component

See Also:
Constant Field Values

JAVASCRIPT_PREFIX

public static final java.lang.String JAVASCRIPT_PREFIX
Represents the "javascript:" printed at the start of javascript event handler code

See Also:
Constant Field Values

RETURN

public static final java.lang.String RETURN
String representing "return false" printed at the end of the javascript event handlers

See Also:
Constant Field Values

ADD_FUNCTION

public static final java.lang.String ADD_FUNCTION
Name of the JavaScript function which is responsible for adding elements from the availble list to the selected list

See Also:
Constant Field Values

ADDALL_FUNCTION

public static final java.lang.String ADDALL_FUNCTION
Name of the JavaScript function which is responsible for selecting all the available items

See Also:
Constant Field Values

REMOVE_FUNCTION

public static final java.lang.String REMOVE_FUNCTION
Name of the JavaScript function which removes items from the seleted list

See Also:
Constant Field Values

REMOVEALL_FUNCTION

public static final java.lang.String REMOVEALL_FUNCTION
Name of the JavaScript function which removes all the items from the seleted list

See Also:
Constant Field Values

MOVEUP_FUNCTION

public static final java.lang.String MOVEUP_FUNCTION
Name of the JavaScript function which moves elements up

See Also:
Constant Field Values

MOVEDOWN_FUNCTION

public static final java.lang.String MOVEDOWN_FUNCTION
Name of the JavaScript function which moves elements down

See Also:
Constant Field Values

UPDATEBUTTONS_FUNCTION

public static final java.lang.String UPDATEBUTTONS_FUNCTION
Name of the JavaScript function that updates the buttons

See Also:
Constant Field Values

AVAILABLE_ONCHANGE_FUNCTION

public static final java.lang.String AVAILABLE_ONCHANGE_FUNCTION
Name of the JavaScript function that handles changes on the available list

See Also:
Constant Field Values

SELECTED_ONCHANGE_FUNCTION

public static final java.lang.String SELECTED_ONCHANGE_FUNCTION
Name of the JavaScript function which handles changes to the selected list

See Also:
Constant Field Values

MULTIPLEADDITIONS_FUNCTION

public static final java.lang.String MULTIPLEADDITIONS_FUNCTION
The name of the JavaScript function used to hook up the correct add and remove functions when the component allows items to be added to the selected items list more than once

See Also:
Constant Field Values

SPACER_STRING

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

SEPARATOR_VALUE

public static final java.lang.String SEPARATOR_VALUE
The string used as a separator between the selected values

See Also:
Constant Field Values
Constructor Detail

AddRemove

public AddRemove()
Constructor for the AddRemove component

Method Detail

getRows

public int getRows()
Get the number of rows to disaplay (the default is 12)

Specified by:
getRows in interface ListManager
Overrides:
getRows in class ListSelectorBase
Returns:
the number of rows to disaplay

getSeparator

public java.lang.String getSeparator()
Get the separator string that is used to separate the selected values on the client. The default value is "|". When the AddRemove component is decoded, the value is taken from a hidden variable whose value is a list of the values of all the options in the list representing the selected items. Consider a case where the AddRemove has a list of options including Assume that these two options are disabled. If the separator string is set to "|", then the value of the hidden variable will be |1|2|. You will only need to set this variable if the string representation of one of the option values contain the character "|". If you do need to change from the default, bear in mind that the value of the hidden component is sent as part of the body of the HTTP request body. Make sure to select a character that does not change the syntax of the request.

Returns:
The separator string.

getSelectedItems

public java.util.Iterator getSelectedItems()
Returns an iterator over the selected items

Returns:
an iterator over the selected items

getAllValues

public java.lang.String getAllValues()
This function returns a String consisting of the String representation of the values of all the available Options, separated by the separator String (see getSeparator())

Returns:
eturns a String consisting of the String representation of the values of all the available Options, separated by the separator String

getSelectedValues

public java.lang.String getSelectedValues()
This function returns a String consisting of the String representation of the values of the selected Options, separated by the separator String

Returns:
a String consisting of the String representation of the values of the selected Options, separated by the separator String

getAddButtonComponent

public javax.faces.component.UIComponent getAddButtonComponent(javax.faces.context.FacesContext context)
Get or create the ADD button. Retrieves the component specified by the addButton facet (if there is one) or creates a new Button component.

Parameters:
context - The FacesContext for the request
Returns:
A UI Component for the Add button

getAddAllButtonComponent

public javax.faces.component.UIComponent getAddAllButtonComponent()
Get or create the ADD button. Retrieves the component specified by the addButton facet (if there is one) or creates a new Button component.

Returns:
A UI Component for the Add button

getRemoveButtonComponent

public javax.faces.component.UIComponent getRemoveButtonComponent()
Get or create the REMOVE button. Retrieves the component specified by the removeButton facet (if there is one) or creates a new Button component.

Returns:
A UI Component for the Remove button

getRemoveAllButtonComponent

public javax.faces.component.UIComponent getRemoveAllButtonComponent()
Get or create the REMOVE button. Retrieves the component specified by the removeButton facet (if there is one) or creates a new Button component.

Returns:
A UI Component for the Remove button

getMoveUpButtonComponent

public javax.faces.component.UIComponent getMoveUpButtonComponent()
Get or create the MOVEUP button. Retrieves the component specified by the moveUpButton facet (if there is one) or creates a new Button component.

Returns:
A UI Component for the MoveUp button

getMoveDownButtonComponent

public javax.faces.component.UIComponent getMoveDownButtonComponent()
Get or create the MOVEDOWN button. Retrieves the component specified by the moveDownButton facet (if there is one) or creates a new Button component.

Returns:
A UI Component for the MoveDown button

getAvailableLabelComponent

public javax.faces.component.UIComponent getAvailableLabelComponent()
Gets or creates a component for the "available" list label. Retrieves the availableLabel facet if one was specified, or creates a new label component.

Returns:
A UIComponent for the list label

getSelectedLabelComponent

public javax.faces.component.UIComponent getSelectedLabelComponent()
Gets or creates a component for the "selected" list label. Retrieves the selectedLabel facet if one was specified, or creates a new label component.

Returns:
A UIComponent for the list label

getHeaderComponent

public javax.faces.component.UIComponent getHeaderComponent()
Gets or creates a component for the "component" list label. Retrieves the componentLabel facet if one was specified, or creates a new label component.

Returns:
A UIComponent for the list label

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
Overrides:
getPrimaryElementID in class ListSelector

getListItems

public java.util.Iterator getListItems(javax.faces.context.FacesContext context,
                                       boolean rulerAtEnd)
                                throws javax.faces.FacesException
Retrieve an Iterator of ListSelector.ListItem representing the available selections only. This method is used by the renderer, to create the options of the list of available items.

Specified by:
getListItems in interface ListManager
Overrides:
getListItems in class ListSelector
Parameters:
context - The FacesContext used for the request
rulerAtEnd - If true, a disabled list item with a blank label is appended at the end of the options. The role of the blank item is to guarantee that the width of the lists do not change when items are moved from one to the other.
Returns:
an Iterator over ListItem.
Throws:
javax.faces.FacesException - If something goes wrong when the options are processed

processOptions

protected void processOptions(javax.faces.context.FacesContext context,
                              java.text.Collator collator,
                              java.util.Locale locale,
                              boolean rulerAtEnd)
Evaluates the list of available Options, creating a ListItem for each one.

Parameters:
context - The FacesContext
rulerAtEnd - the end of the options. The role of the blank item is to guarantee that the width of the lists do not change when items are moved from one to the other.

getSelectedListItems

public java.util.Iterator getSelectedListItems()
Retrieve an Iterator of ListSelector.ListItem representing the selected selections only. This method is used by the renderer, to create the options of the list of selected items. It is also used when calculating a string representation of the value of the component.

Returns:
An Iterator over the selected ListItem

markSelectedListItems

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

Overrides:
markSelectedListItems in class ListSelector
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).

mainListSubmits

public boolean mainListSubmits()
Specified by:
mainListSubmits in interface ListManager
Overrides:
mainListSubmits in class ListSelector