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

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.RbCbSelectorBase
                              extended bycom.sun.rave.web.ui.component.RbCbSelector
All Implemented Interfaces:
javax.faces.component.EditableValueHolder, SelectorManager, javax.faces.component.StateHolder, javax.faces.component.ValueHolder
Direct Known Subclasses:
CheckboxBase, RadioButtonBase

public class RbCbSelector
extends RbCbSelectorBase

Superclass for Checkbox and RadioButton.


Field Summary
static java.lang.String IMAGE_FACET
          Image facet name.
static java.lang.String LABEL_FACET
          Label facet name.
 
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
RbCbSelector()
           
 
Method Summary
protected  void addToRequestMap(javax.faces.context.FacesContext context, java.lang.String groupName)
          Implemented by subclasses in order to reflect the selection state of this component id part of a group.
protected  javax.faces.component.UIComponent createImageComponent()
          Create a com.sun.rave.web.ui.component.ImageComponent to represent the image for this component.
protected  javax.faces.component.UIComponent createLabelComponent()
          Create a com.sun.rave.web.ui.component.Label to represent the label for this component.
 void encodeBegin(javax.faces.context.FacesContext context)
          Encode the component.
 java.lang.Object getConvertedValue(javax.faces.context.FacesContext context, java.lang.Object submittedValue)
          Convert the submittedValue argument.
 java.lang.Object getConvertedValue(javax.faces.context.FacesContext context, RbCbSelector component, java.lang.Object submittedValue)
          Convert the submittedValue argument.
 javax.faces.component.UIComponent getImageComponent()
          Returns a UIComponent that represents the image for this component.
 javax.faces.component.UIComponent getLabelComponent()
          Returns a UIComponent that represents the label for this component.
 java.lang.Object getSelectedValue()
          Return the value of the selectedValue property.
 boolean isChecked()
          Return true if the control is checked.
 
Methods inherited from class com.sun.rave.web.ui.component.RbCbSelectorBase
getFamily, getImageURL, getName, getSelected, getValueBinding, restoreState, saveState, setImageURL, setName, setSelected, setSelectedValue, setValueBinding
 
Methods inherited from class com.sun.rave.web.ui.component.Selector
compareValues, getLabelLevel, getRendersChildren, getValueAsReadOnly, isMultiple, setMultiple, 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, getStyle, getStyleClass, getTabIndex, getToolTip, isDisabled, isReadOnly, isVisible, setDisabled, setItems, setLabel, setLabelLevel, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setReadOnly, setStyle, setStyleClass, setTabIndex, setToolTip, setVisible
 
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, 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.SelectorManager
getClientId, getOnChange, getStyle, getStyleClass, getTabIndex, isDisabled, isReadOnly
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue, setConverter
 

Field Detail

IMAGE_FACET

public static final java.lang.String IMAGE_FACET
Image facet name.

See Also:
Constant Field Values

LABEL_FACET

public static final java.lang.String LABEL_FACET
Label facet name.

See Also:
Constant Field Values
Constructor Detail

RbCbSelector

public RbCbSelector()
Method Detail

addToRequestMap

protected void addToRequestMap(javax.faces.context.FacesContext context,
                               java.lang.String groupName)
Implemented by subclasses in order to reflect the selection state of this component id part of a group. This method is called if the component is part of a group.

Parameters:
context - the context for this request.
groupName - the value of the name property.

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context)
                 throws java.io.IOException
Encode the component.

If this component is part of a group, ensure that the initial state is reflected in the request map by calling addToRequestMap.

Parameters:
context - the context for this request.
Throws:
java.io.IOException

getConvertedValue

public java.lang.Object getConvertedValue(javax.faces.context.FacesContext context,
                                          java.lang.Object submittedValue)
                                   throws javax.faces.convert.ConverterException
Convert the submittedValue argument.

If there is a renderer for this component, its getConvertedValue() method is called and the value returned by that method is returned.

If there is no renderer, and submittedValue is not an instance of String[] or String a ConverterException is thrown.

The submittedValue indicates selected if it is String[1].length() != 0 or String.length() != 0.

If not selected and getSelectedValue() returns an instance of Boolean, Boolean.FALSE is returned.

If not selected and it's not a boolean control then an unselected value is returned appropriate for the type of the selected property. If the type of the selected property evaluates to a primitive type by virtue of a value binding the appropriate MIN_VALUE constant is returned. For example if the type is int, new Integer(Integer.MIN_VALUE) is returned.
If the type is not a primitive value "" is returned.

If the control is selected ConversionUtilities.convertValueToObject() is called to convert submittedValue.

If ConversionUtilities.convertValueToObject() returns submittedValue, the value of the getSelectedValue() property is returned, else the value returned by ConversionUtilities.convertValueToObject() is returned.

Overrides:
getConvertedValue in class Selector
Parameters:
context - the context of this request.
submittedValue - the submitted String value of this component.
Throws:
javax.faces.convert.ConverterException

getConvertedValue

public java.lang.Object getConvertedValue(javax.faces.context.FacesContext context,
                                          RbCbSelector component,
                                          java.lang.Object submittedValue)
                                   throws javax.faces.convert.ConverterException
Convert the submittedValue argument.

If submittedValue is not an instance of String[] or String a ConverterException is thrown.

The submittedValue indicates selected if it is String[1].length() != 0 or String.length() != 0.

If not selected and getSelectedValue() returns an instance of Boolean, Boolean.FALSE is returned.

If not selected and it's not a boolean control then an unselected value is returned appropriate for the type of the selected property. If the type of the selected property evaluates to a primitive type by virtue of a value binding the appropriate MIN_VALUE constant is returned. For example if the type is int, new Integer(Integer.MIN_VALUE) is returned.
If the type is not a primitive value "" is returned.

If the control is selected ConversionUtilities.convertValueToObject() is called to convert submittedValue.

If ConversionUtilities.convertValueToObject() returns submittedValue, the value of the getSelectedValue() property is returned, else the value returned by ConversionUtilities.convertValueToObject() is returned.

Parameters:
context - the context of this request.
component - an RbCbSelector instance.
submittedValue - the submitted String value of this component.
Throws:
javax.faces.convert.ConverterException

getSelectedValue

public java.lang.Object getSelectedValue()
Return the value of the selectedValue property. If selectedValue is null, then a Boolean true instance is returned and the control will behave as a boolean control.

Overrides:
getSelectedValue in class RbCbSelectorBase

isChecked

public boolean isChecked()
Return true if the control is checked. A control is checked when the selectedValue property is equal to the selected property.


getLabelComponent

public javax.faces.component.UIComponent getLabelComponent()
Returns a UIComponent that represents the label for this component.

If a "label" facet exists, the UIComponent associated with that facet is returned.
If a "label" facet does not exist and the label property is not null, createLabelComponent is called to create the label component.


getImageComponent

public javax.faces.component.UIComponent getImageComponent()
Returns a UIComponent that represents the image for this component.

If an "image" facet exists, the UIComponent associated with that facet is returned.
If an "image" facet does not exist and the imageURL property is not null, createImageComponent() is called to create the image component.


createLabelComponent

protected javax.faces.component.UIComponent createLabelComponent()
Create a com.sun.rave.web.ui.component.Label to represent the label for this component.


createImageComponent

protected javax.faces.component.UIComponent createImageComponent()
Create a com.sun.rave.web.ui.component.ImageComponent to represent the image for this component.