org.apache.beehive.netui.tags.html
Class CheckBoxGroup

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by HtmlGroupBaseTag
                  extended by CheckBoxGroup
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, IDataAccessProvider, HtmlConstants, IAttributeConsumer, INetuiTag

public class CheckBoxGroup
extends HtmlGroupBaseTag

Groups a collection of CheckBoxOptions, and handles databinding of their values. CheckBoxGroup binds to an Iterator of Strings. If CheckBoxGroup uses any Format tags, it must have those tags come before any nested CheckBoxOption tags.

See Also:
Serialized Form
Example
In this first sample, the <netui:checkBoxGroup> submits data to the Form Bean field preferredColors.
    <netui:checkBoxGroup
            dataSource="actionForm.preferredColors"
            optionsDataSource="${pageFlow.colors}" />
The optionsDataSource attribute points to a get method for a String[] on the Controller file:
    String[] colors = new String[] {"Red", "Blue", "Green", "Yellow", "White", "Black"};

    public String[] getColors()
    {
        return colors;
    }
This automatically renders the appropriate set of checkbox options within the <checkBoxGroup>:
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Red">Red</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Blue">Blue</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Green">Green</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Yellow">Yellow</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="White">White</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Black">Black</input>
The defaultValue attribute may point to a String or a String[].
    <netui:checkBoxGroup
            dataSource="actionForm.preferredColors"
            optionsDataSource="${pageFlow.colors}"
            defaultValue="${pageFlow.defaultColor}" />
And in the Controller:
    String defaultColor = new String ("Blue");
    ...
or
    String[] defaultColor = new String[] {"Red", "Blue"};
    ...
In either case, the appropriate checkbox options will appear checked in the browser.
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Red" checked="true">Red</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Blue" checked="true">Blue</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Green">Green</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Yellow">Yellow</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="White">White</input>
    <input type="checkbox" name="wlw-checkbox_group_key:{actionForm.preferredColors}" value="Black">Black</input>

Nested Class Summary
static class CheckBoxGroup.CheckboxGroupPrefixHandler
          The handler for naming and indexing the CheckBoxGroup.
 
Field Summary
static String CHECKBOXGROUP_KEY
          This is the name of the prefixHandler for the checkbox grup.
 
Fields inherited from class HtmlGroupBaseTag
_cr, _dataSource, _defaultValue, _disabled, _labelStyle, _labelStyleClass, _optionsDataSource, _repCurItem, _repeater, _repIdx, HORIZONTAL_VALUE, VERTICAL_VALUE
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface HtmlConstants
ABBR, ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, AREA, AXIS, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, BUTTON, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COLSPAN, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEADERS, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LANGUAGE, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, ROWSPAN, RULES, SCOPE, SCRIPT, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TBODY, TD, TEXT, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
CheckBoxGroup()
           
 
Method Summary
 void createHiddenField(AbstractRenderAppender results)
           
 int doAfterBody()
          Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.
 int doEndTag()
          Render the set of CheckBoxOptions.
 int doStartTag()
          Determine the set of matches for the CheckBoxGroup
protected  List getNamingChain()
          Return an ArrayList which represents a chain of INameInterceptor objects.
 String getTagName()
          Return the name of the Tag.
 boolean isMatched(String value, Boolean defaultValue)
          Checks whether the given value matches one of the CheckBoxGroup's selected CheckBoxOptions.
protected  void localRelease()
          Release any acquired resources.
 
Methods inherited from class HtmlGroupBaseTag
addOption, doNaming, evaluateDataSource, evaluateOptionsDataSource, getCurrentIndex, getCurrentItem, getCurrentMetadata, getDataSource, getLabelStyle, getLabelStyleClass, getOptionsDataSource, getProviderParent, getQualifiedDataSourceName, isDisabled, isRepeater, isVertical, setAttribute, setDataSource, setDefaultValue, setDisabled, setLabelStyle, setLabelStyleClass, setOptionsDataSource, setOrientation, setRepeater, setStyle, setStyleClass
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNearestForm, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Field Detail

CHECKBOXGROUP_KEY

public static final String CHECKBOXGROUP_KEY
This is the name of the prefixHandler for the checkbox grup.

See Also:
Constant Field Values
Constructor Detail

CheckBoxGroup

public CheckBoxGroup()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
the name of the tag.

getNamingChain

protected List getNamingChain()
Return an ArrayList which represents a chain of INameInterceptor objects. This method by default returns null and should be overridden by objects that support naming.

Overrides:
getNamingChain in class HtmlGroupBaseTag
Returns:
an ArrayList that will contain INameInterceptor objects.

isMatched

public boolean isMatched(String value,
                         Boolean defaultValue)
Checks whether the given value matches one of the CheckBoxGroup's selected CheckBoxOptions.

Specified by:
isMatched in class HtmlGroupBaseTag
Parameters:
value - Value to be compared
Returns:
boolean

doStartTag

public int doStartTag()
               throws JspException
Determine the set of matches for the CheckBoxGroup

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doAfterBody

public int doAfterBody()
                throws JspException
Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.

Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doEndTag

public int doEndTag()
             throws JspException
Render the set of CheckBoxOptions.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

createHiddenField

public void createHiddenField(AbstractRenderAppender results)
                       throws JspException
Throws:
JspException

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class HtmlGroupBaseTag