com.arsdigita.bebop.form
Class MultipleSelectPairWidget

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.FormSection
              extended bycom.arsdigita.bebop.FormStep
                  extended bycom.arsdigita.bebop.form.MultipleSelectPairWidget
All Implemented Interfaces:
Cloneable, Component, Container, Lockable

public class MultipleSelectPairWidget
extends FormStep

Multiple select widget pair for knowledge types. This FormStep displays two multiple select widgets, one which contains possible the user may want to add, and the right displays the options that are currently applicable.

To use the widget, you should call setLeftMultipleSelect(RequestLocal) and setRightMultipleSelect(RequestLocal) and pass in the appropriate collections to initialize the MutlipleSelect options. Then, in the process listener of the form in which the MultipleSelectPairWidget is embedded, call getSelectedOptions(PageState) and getUnselectedOptions(PageState) to get the chosen values. The process listener for the parent form must use the Submit.isSelected(ps) so that the process listener can distinguish between different types of form submits.

Note that the right multiple select can be empty and does not need to be set. This class also uses a relatively inefficient implementation of removeOption in OptionGroup so that operations run in O(N^2). This can be reduced to O(N) with a more optimal implementation of OptionGroup.

Version:
$Revision: #10 $ $Date: 2004/04/07 $
See Also:
Option, OptionGroup

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.FormSection
m_formModel, m_panel
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
MultipleSelectPairWidget()
          This create a standard MultipleSelectPairWidget with the default names used for internal widgets.
MultipleSelectPairWidget(String nameQualifier)
           
 
Method Summary
 void generateXML(PageState state, Element element)
          Builds an XML subtree for this component under the specified parent.
 Widget getLeftSelect()
          This returns the left select widget so that callers can have access to the underlying parameters and other features (e.g.
 Widget getRightSelect()
          This returns the left select widget so that callers can have access to the underlying parameters and other features (e.g.
 String[] getSelectedOptions(PageState ps)
          Returns the selected options, those selected from the left hand widget
 String[] getUnselectedOptions(PageState ps)
          Returns the unselected options, those removed from the right hand widget
 boolean isSelected(PageState ps)
           
 boolean leftSideChanges()
          This returns an indication of whether or not the left multiple select changes as items are moved from the left to the right.
 void setLeftMultipleSelect(RequestLocal collection)
           
 void setLeftMultipleSelectMap(RequestLocal map)
          This lets the user pass in a RequestLocal that returns a java.util.Map that contains the option value as the key and the actual option as the map value.
 void setLeftSideChanges(boolean doesChange)
           
 void setMultipleSelectSize(int size)
           
 void setRightMultipleSelect(RequestLocal collection)
           
 void setRightMultipleSelectMap(RequestLocal map)
          This lets the user pass in a RequestLocal that returns a java.util.Map that contains the option value as the key and the actual option as the map value.
 
Methods inherited from class com.arsdigita.bebop.FormStep
createInitListener, fireProcess, fireSubmitted, fireValidate, isInitialized, register, register
 
Methods inherited from class com.arsdigita.bebop.FormSection
add, add, addCancelListener, addInitListener, addProcessListener, addSubmissionListener, addValidationListener, children, contains, createProcessListener, createSubmissionListener, createValidationListener, fireCancel, fireInit, forwardInit, forwardProcess, forwardSubmission, forwardValidation, get, getModel, getPanel, indexOf, isEmpty, lock, process, removeCancelListener, removeInitListener, removeProcessListener, removeSubmissionListener, removeValidationListener, respond, size
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

MultipleSelectPairWidget

public MultipleSelectPairWidget()
This create a standard MultipleSelectPairWidget with the default names used for internal widgets.


MultipleSelectPairWidget

public MultipleSelectPairWidget(String nameQualifier)
Method Detail

isSelected

public boolean isSelected(PageState ps)

setLeftMultipleSelect

public void setLeftMultipleSelect(RequestLocal collection)
Parameters:
collection - A collection of Option objects

setLeftMultipleSelectMap

public void setLeftMultipleSelectMap(RequestLocal map)
This lets the user pass in a RequestLocal that returns a java.util.Map that contains the option value as the key and the actual option as the map value. When populating the left select, the system will use this map before falling back to the default map.


setRightMultipleSelectMap

public void setRightMultipleSelectMap(RequestLocal map)
This lets the user pass in a RequestLocal that returns a java.util.Map that contains the option value as the key and the actual option as the map value. When populating the left select, the system will use this map before falling back to the default map.


getLeftSelect

public Widget getLeftSelect()
This returns the left select widget so that callers can have access to the underlying parameters and other features (e.g. in case they need to add a ParameterListener)


getRightSelect

public Widget getRightSelect()
This returns the left select widget so that callers can have access to the underlying parameters and other features (e.g. in case they need to add a ParameterListener)


setLeftSideChanges

public void setLeftSideChanges(boolean doesChange)
Parameters:
doesChange - This indicates whether the items in the "to add" select box are removed as they are added to the "to remove" select box. That is, as choices are selected, should they be removed from the list of choices? This defaults to true.

leftSideChanges

public boolean leftSideChanges()
This returns an indication of whether or not the left multiple select changes as items are moved from the left to the right.


setRightMultipleSelect

public void setRightMultipleSelect(RequestLocal collection)
Parameters:
collection - A collection of Option objects

getSelectedOptions

public String[] getSelectedOptions(PageState ps)
Returns the selected options, those selected from the left hand widget

Returns:
array of options

getUnselectedOptions

public String[] getUnselectedOptions(PageState ps)
Returns the unselected options, those removed from the right hand widget

Returns:
array of options

generateXML

public void generateXML(PageState state,
                        Element element)
Description copied from class: FormSection
Builds an XML subtree for this component under the specified parent. Uses the request values stored in state.

This method generates DOM to be used with the XSLT template to produce the appropriate output.

Specified by:
generateXML in interface Component
Overrides:
generateXML in class FormStep

setMultipleSelectSize

public void setMultipleSelectSize(int size)


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC