com.sun.rave.web.ui.renderer
Class CheckboxGroupRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by com.sun.rave.web.ui.renderer.AbstractRenderer
          extended by com.sun.rave.web.ui.renderer.CheckboxGroupRenderer

public class CheckboxGroupRenderer
extends AbstractRenderer

The CheckboxGroupRenderer renders a CheckboxGroup component as set of checkboxes. The CheckboxGroupRenderer creates an instance of Checkbox for each Option instance in the Array, Map, or Collection returned by the CheckboxGroup getItems() method and renders them. It also creates a Label component and renders it as the label for the group.

Zero or more checkboxes may be selected. The value of the CheckboxGroup will determine which checkboxes shall be initially selected and subsequetly hold the current selections.

The checkboxes are rendered as a single column or some number of rows and columns. The rows and columns are rendered as a table as defined by the RowColumnRenderer superclass. The elements that make up the checkbox occupy a cell in the table. The style class selector for the group elements is identified by a java constants defined in the ThemeStyles class.

The name property of each checkbox is the component id of the CheckboxGroup instance. The id of a Checkbox component is cbgrpid_N where cbgrpid is the id of the CheckboxGroup instance and _N is the nth checkbox.

The CheckboxGroup is decoded by identifying the CheckboxGroup instance component id which is returned as a request parameter. It represents the name attribute of the selected checkbox's <input> element. The values of the identified request parameter are assigned as the submitted value of the CheckboxGroup component.

If the items property of the CheckboxGroup is null or zero length, no output is produced.


Field Summary
protected static int CAPTION_STYLE
          Constant indicating a TD element stlye is desired.
protected static int CELLEVEN_STYLE
          Constant indicating a TD element style selector is desired.
protected static int CELLODD_STYLE
          Constant indicating a TD element style selector is desired.
protected static int GRP
          The define constant indicating the style class for the top level TABLE element.
protected static int GRP_CAPTION
          The define constant indicating the style class for the CSS table CAPTION (a CELL element).
protected static int GRP_CELL_EVEN
          The define constant indicating the style class for the even cells.
protected static int GRP_CELL_ODD
          The define constant indicating the style class for the odd cells.
protected static int GRP_LABEL
          The define constant indicating the style class for a disabled CSS table CAPTION (a LABEL) element.
protected static int GRP_LABEL_DIS
          The define constant indicating the style class for a disabled CSS table CAPTION (a LABEL) element.
protected static int GRP_ROW_EVEN
          The define constant indicating the style class for the even rows.
protected static int GRP_ROW_ODD
          The define constant indicating the style class for the odd rows.
protected static int IMAGE
          The define constant indicating the style class for the IMG element.
protected static int IMAGE_DIS
          The define constant indicating the style class for a disabled IMG element.
protected static int INPUT
          The define constant indicating the style class for an INPUT element.
protected static int INPUT_DIS
          The define constant indicating the style class for a disabled INPUT element.
protected static int LABEL
          The define constant indicating the style class for the LABEL element.
protected static int LABEL_DIS
          The define constant indicating the style class for a disabled LABEL element.
protected static int LABEL_LVL_DEF
          The define constant indicating the default label level style class for a LABEL element.
protected static int LABEL_LVL1
          The define constant indicating the label level style class for a LABEL element.
protected static int LABEL_LVL2
          The define constant indicating the label level style class for a LABEL element.
protected static int LABEL_LVL3
          The define constant indicating the label level style class for a LABEL element.
protected static int ROWEVEN_STYLE
          Constant indicating a TR element style selector is desired.
protected static int ROWODD_STYLE
          Constant indicating a TR element style selector is desired.
protected  java.lang.String[] styles
          The style constants defined in ThemeStyles mapped to the value of constants defined in SelectorGroupRenderer.
protected static int TABLE_STYLE
          Constant indicating a TABLE element style selector is desired.
 
Fields inherited from class com.sun.rave.web.ui.renderer.AbstractRenderer
BUNDLE, EVENTS_ATTRIBUTES, I18N_ATTRIBUTES
 
Constructor Summary
CheckboxGroupRenderer()
          Creates a new instance of CheckboxGroupRenderer
 
Method Summary
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Decode the RadioButtonGroup or CheckboxGroup selection.
 void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Render the child components of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.
protected  Option[] getItems(Selector selector)
           
protected  java.lang.String getRowColumnStyle(Theme theme, int styleCode)
          Pass on the style request from the RowColumnRenderer to the SelectorGroupRenderer subclass.
protected  javax.faces.component.UIComponent getSelectorComponent(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, java.lang.String id, Option option)
          Return a Checkbox component to render.
protected  java.lang.String getStyle(Theme theme, int styleCode, int styleLevelCode)
          Return the style class name and level for the structural element indicated by styleCode
protected  java.lang.String[] getStyles()
          Return style constants for a Checkbox component.
protected  void renderCaption(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer)
          Called by the RowColumnRenderer superclass when the group label should be rendered.
protected  void renderCellContent(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer, int itemN)
          Implemented by a subclass.
protected  void renderEmptyCell(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer)
          Called from the renderCellContent method implemented in the sublclass when there are no more controls to render.
 void renderEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer)
          CheckboxGroupRenderer renders the entire CheckboxGroup component within the renderEnd method.
protected  void renderRowColumnLayout(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer, int rows, int columns)
          Called from a subclass when rendering is to begin
protected  void renderSelectorGroup(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer, int columns)
          Called from the renderEnd method of the subclass to begin rendering the component.
 void renderStart(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer)
          Ensure that the component to be rendered is a CheckboxGroup instance.
protected  void transferEventAttributes(Selector group, RbCbSelector rbcb)
           
 
Methods inherited from class com.sun.rave.web.ui.renderer.AbstractRenderer
addBooleanAttributes, addCoreAttributes, addIntegerAttributes, addStringAttributes, encodeBegin, encodeEnd, getApplication, getAsObject, getAsString, getExternalContext, getFacesContext, getSubmittedValue, isDisabled, isPortlet, isReadOnly, renderAttributes, renderMarkup, setSubmittedValue
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, getConvertedValue, getRendersChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

styles

protected java.lang.String[] styles
The style constants defined in ThemeStyles mapped to the value of constants defined in SelectorGroupRenderer.


GRP

protected static final int GRP
The define constant indicating the style class for the top level TABLE element.

See Also:
Constant Field Values

GRP_CAPTION

protected static final int GRP_CAPTION
The define constant indicating the style class for the CSS table CAPTION (a CELL element).

See Also:
Constant Field Values

GRP_LABEL

protected static final int GRP_LABEL
The define constant indicating the style class for a disabled CSS table CAPTION (a LABEL) element.

See Also:
Constant Field Values

GRP_LABEL_DIS

protected static final int GRP_LABEL_DIS
The define constant indicating the style class for a disabled CSS table CAPTION (a LABEL) element.

See Also:
Constant Field Values

GRP_ROW_EVEN

protected static final int GRP_ROW_EVEN
The define constant indicating the style class for the even rows.

See Also:
Constant Field Values

GRP_ROW_ODD

protected static final int GRP_ROW_ODD
The define constant indicating the style class for the odd rows.

See Also:
Constant Field Values

GRP_CELL_EVEN

protected static final int GRP_CELL_EVEN
The define constant indicating the style class for the even cells.

See Also:
Constant Field Values

GRP_CELL_ODD

protected static final int GRP_CELL_ODD
The define constant indicating the style class for the odd cells.

See Also:
Constant Field Values

INPUT

protected static final int INPUT
The define constant indicating the style class for an INPUT element.

See Also:
Constant Field Values

INPUT_DIS

protected static final int INPUT_DIS
The define constant indicating the style class for a disabled INPUT element.

See Also:
Constant Field Values

LABEL

protected static final int LABEL
The define constant indicating the style class for the LABEL element.

See Also:
Constant Field Values

LABEL_DIS

protected static final int LABEL_DIS
The define constant indicating the style class for a disabled LABEL element.

See Also:
Constant Field Values

IMAGE

protected static final int IMAGE
The define constant indicating the style class for the IMG element.

See Also:
Constant Field Values

IMAGE_DIS

protected static final int IMAGE_DIS
The define constant indicating the style class for a disabled IMG element.

See Also:
Constant Field Values

LABEL_LVL1

protected static final int LABEL_LVL1
The define constant indicating the label level style class for a LABEL element.

See Also:
Constant Field Values

LABEL_LVL2

protected static final int LABEL_LVL2
The define constant indicating the label level style class for a LABEL element.

See Also:
Constant Field Values

LABEL_LVL3

protected static final int LABEL_LVL3
The define constant indicating the label level style class for a LABEL element.

See Also:
Constant Field Values

LABEL_LVL_DEF

protected static final int LABEL_LVL_DEF
The define constant indicating the default label level style class for a LABEL element.

See Also:
Constant Field Values

TABLE_STYLE

protected static final int TABLE_STYLE
Constant indicating a TABLE element style selector is desired.

See Also:
Constant Field Values

CAPTION_STYLE

protected static final int CAPTION_STYLE
Constant indicating a TD element stlye is desired. This selector is used for the TD element that contains the group label.

See Also:
Constant Field Values

ROWEVEN_STYLE

protected static final int ROWEVEN_STYLE
Constant indicating a TR element style selector is desired. The selector is applied to an odd row.

See Also:
Constant Field Values

ROWODD_STYLE

protected static final int ROWODD_STYLE
Constant indicating a TR element style selector is desired. The selector is applied to an even row.

See Also:
Constant Field Values

CELLEVEN_STYLE

protected static final int CELLEVEN_STYLE
Constant indicating a TD element style selector is desired. The selector is applied to an even column.

See Also:
Constant Field Values

CELLODD_STYLE

protected static final int CELLODD_STYLE
Constant indicating a TD element style selector is desired. The selector is applied to an odd column.

See Also:
Constant Field Values
Constructor Detail

CheckboxGroupRenderer

public CheckboxGroupRenderer()
Creates a new instance of CheckboxGroupRenderer

Method Detail

renderStart

public void renderStart(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component,
                        javax.faces.context.ResponseWriter writer)
                 throws java.io.IOException
Ensure that the component to be rendered is a CheckboxGroup instance. Actual rendering occurs during the renderEnd method.

Overrides:
renderStart in class AbstractRenderer
Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
writer - ResponseWriter to which the element start should be rendered
Throws:
java.io.IOException - if an input/output error occurs

renderEnd

public void renderEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component,
                      javax.faces.context.ResponseWriter writer)
               throws java.io.IOException
CheckboxGroupRenderer renders the entire CheckboxGroup component within the renderEnd method.

Overrides:
renderEnd in class AbstractRenderer
Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
writer - ResponseWriter to which the element start should be rendered
Throws:
java.io.IOException - if an input/output error occurs

getSelectorComponent

protected javax.faces.component.UIComponent getSelectorComponent(javax.faces.context.FacesContext context,
                                                                 javax.faces.component.UIComponent component,
                                                                 Theme theme,
                                                                 java.lang.String id,
                                                                 Option option)
Return a Checkbox component to render.

Parameters:
context - FacesContext for the current request
component - CheckboxGroup component rendered
theme - Theme for the component
option - the Option being rendered.
id - the new component's id.

getStyles

protected java.lang.String[] getStyles()
Return style constants for a Checkbox component.


decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
Decode the RadioButtonGroup or CheckboxGroup selection. If the component clientId is found as a request parameter, which is rendered as the value of the name attribute of the INPUT elements of type radio or checkbox, the String[] value is assigned as the submitted value on the component.

In the case of a CheckboxGroup component the array may have zero or more elements. In the case of RadioButtonGroup there is always only one element.

If the component clientId is not found as a request parameter a String[0] is assigned as the submitted value, meaning that this is a CheckboxGroup component with no check boxes selected.

Overrides:
decode in class AbstractRenderer
Parameters:
context - FacesContext for the request we are processing.
component - The RadioButtonGroup component to be decoded.

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws java.io.IOException
Render the child components of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered. This method will only be called if the rendersChildren property of this component is true.

Overrides:
encodeChildren in class AbstractRenderer
Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
Throws:
java.io.IOException - if an input/output error occurs

renderSelectorGroup

protected void renderSelectorGroup(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent component,
                                   Theme theme,
                                   javax.faces.context.ResponseWriter writer,
                                   int columns)
                            throws java.io.IOException
Called from the renderEnd method of the subclass to begin rendering the component.

Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
writer - ResponseWriter to which the HTML will be output
columns - the number of columns to use when rendering the controls
Throws:
java.io.IOException

getItems

protected Option[] getItems(Selector selector)

renderCellContent

protected void renderCellContent(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component,
                                 Theme theme,
                                 javax.faces.context.ResponseWriter writer,
                                 int itemN)
                          throws java.io.IOException
Implemented by a subclass. Called when subclass should render the contents of the cell for the itemN'th renderer cell.

Parameters:
context - FacesContext for the current request
component - component being rendered
writer - ResponseWriter to which the HTML is rendered
itemN - the nth cell to be rendered.
Throws:
java.io.IOException

renderCaption

protected void renderCaption(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             Theme theme,
                             javax.faces.context.ResponseWriter writer)
                      throws java.io.IOException
Called by the RowColumnRenderer superclass when the group label should be rendered.

Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
theme - Theme for the request we are processing.
writer - ResponseWriter to which the HTML will be output
Throws:
java.io.IOException

renderEmptyCell

protected void renderEmptyCell(javax.faces.context.FacesContext context,
                               javax.faces.component.UIComponent component,
                               Theme theme,
                               javax.faces.context.ResponseWriter writer)
                        throws java.io.IOException
Called from the renderCellContent method implemented in the sublclass when there are no more controls to render.

Parameters:
context - FacesContext for the request we are processing.
component - UIComponent to be decoded.
theme - Theme for the request we are processing.
writer - ResponseWriter to which the HTML will be output
Throws:
java.io.IOException

getRowColumnStyle

protected final java.lang.String getRowColumnStyle(Theme theme,
                                                   int styleCode)
Pass on the style request from the RowColumnRenderer to the SelectorGroupRenderer subclass.

Parameters:
theme - Theme for the request we are processing.
styleCode - the desired style class constant

getStyle

protected java.lang.String getStyle(Theme theme,
                                    int styleCode,
                                    int styleLevelCode)
Return the style class name and level for the structural element indicated by styleCode

Parameters:
styleCode - identifies the style class for the element about to be rendered.
styleLevelCode - identifies the style class level for the element about to be rendered.

transferEventAttributes

protected void transferEventAttributes(Selector group,
                                       RbCbSelector rbcb)

renderRowColumnLayout

protected void renderRowColumnLayout(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIComponent component,
                                     Theme theme,
                                     javax.faces.context.ResponseWriter writer,
                                     int rows,
                                     int columns)
                              throws java.io.IOException
Called from a subclass when rendering is to begin

Parameters:
context - FacesContext for the current request
component - RadioButtonGroup component rendered
writer - ResponseWriter to which the HTML is rendered
rows - the number of rows to render
columns - the number of columns to render
Throws:
java.io.IOException