This tag renders two listboxes (one for available options, one
for selected options) together with buttons to move the options
between the lists, and optionally to order the selected options.
Use the items attribute to associate the component
with an array, collection or map of
com.sun.rave.web.ui.model.Option and the
selected attribute to associate the component with a
model object that represents the selected items. The model object
must be an array of objects, whose values must be represented by
the values on the com.sun.rave.web.ui.model.Options.
Component layout and Facet structure
The component can be laid out using either horizonal layout
(the default) or vertical layout (if the vertical
attribute is set to true).
In the diagrams below, facet child
components are shown as light
blue. Non-facet areas are violet.
Horizontal layout
In horizontal layout, the component
label (or header) may be shown either above the component
(if the labelOnTopattribute is true) or next to the
component as shown in the diagram.
addButton:
Use this facet to replace the standard "Add" button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_addButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
add() function. See the section on JavaScript for details.
removeButton:
Use this facet to replace the standard "Remove"
button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_removeButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
remove() function. See the section on JavaScript for details.
addAllButton:
Use this facet to replace the standard "Add All"
button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_addAllButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
addAll() function. See the section on JavaScript for details.
removeAllButton:
Use this facet to replace the standard "Remove All"
button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_removeAllButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
removeAll() function. See the section on JavaScript for details.
moveUpButton:
Use this facet to replace the standard "Move Up"
button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_moveUpButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
moveUp() function. See the section on JavaScript for details.
moveDownButton:
Use this facet to replace the standard "Move Down"
button. If
you use a facet to replace this component, the JSF ID of this
component should be the ID given to the AddRemove component with
_moveDownButton appended at the end. If you wish to use the
JavaScript function associated with the default button, use the
moveDown() function. See the section on JavaScript for details.
header:
Use this facet to create a header for the
component. The facet will replace the component label.
footer:
Use this facet to create a footer for the
component.
Client-side JavaScript functions
When the component is rendered, a JavaScript object corresponding
to the component is created. The name of the variable is AddRemove_
followed by the component's DOM id where the colons have been replaced
by underscores. For example, if the id of the component is
listform:addremove then the JavaScript variable name will
be AddRemove_listform_addremove. To manipulate the
component on the client side, you may invoke functions on the
JavaScript object. With reference to the id above, to add all elements
on the available list that the user has selected, invoke
AddRemove_listform_addremove.add().
add(): the highlighted items on the available list
are moved to the selected list.
addAll(): all non-disabled items on the available list
are moved to the selected list.
remove(): the highlighted items on the selected list
are moved to the available list.
removeAll(): all non-disabled items on the selected list
are moved to the available list.
moveUp(): the highlighted items on the selected list
are moved up one position.
moveDown(): the highlighted items on the selected list
are moved down one position.
updateButtons(): this function ensures that the
buttons are enabled/disabled based on the current selections in
the lists. Invoke this function if you programmatically modify the
selections on the available or selected list using client-side
scripts. You do not need to invoke it when using any of the
functions listed above, as they already invoke this function at
the end.
Configuring the AddRemove tag
Examples
The component gets the options from a managed bean called
AirportBean. The selections are stored in another managed bean
(AirportSelectionBean). The selectAll attribute indicates that the
Add All and Remove All buttons should be
shown. A label for the component as a whole (label) is shown
next to the component (labelOnTop is false). Labels have
been specified for the list of available items and for the list of
selected items. The sorted attribute indicates that the options on
the list will be shown in alphabetical order.
As in the previous example, with the following exceptions: The
component is rendered using vertical layout (in this case, the main
component label is always rendered above the component).
The moveButtons attribute indicates that the
Move Up and Move Down buttons should be
shown.
Return the identifier of the component family to which this
component belongs. This identifier, in conjunction with the value
of the rendererType property, may be used to select
the appropriate
Renderer for this component instance.
Set this attribute to true if the component should allow items
from the available list to be added more than one to the
selected list, that is, if the selected list should allow duplicate entries.
If true, the items on the available options list are shown in alphabetical
order. The item on the selected options list are also shown in alphabetical order,
unless the moveButtons attribute is true, in which case the user is expected to
order the elements.
public void setDuplicateSelections(boolean duplicateSelections)(Code)
Set this attribute to true if the component should allow items
from the available list to be added more than one to the
selected list, that is, if the selected list should allow duplicate entries.
If true, the items on the available options list are shown in alphabetical
order. The item on the selected options list are also shown in alphabetical order,
unless the moveButtons attribute is true, in which case the user is expected to
order the elements.