BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.html
Class CheckBoxGroup

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.DataSourceTag
                  extended by com.bea.wlw.netui.tags.DefaultableDataSourceTag
                      extended by com.bea.wlw.netui.tags.OptionsDataSourceTag
                          extended by com.bea.wlw.netui.tags.html.CheckBoxGroup
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class CheckBoxGroup
extends OptionsDataSourceTag

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.

Attribute Descriptions
AttributeRequiredRuntime Expression EvaluationData Bindable
dataSourceYesNoRead / Write
The name of a form bean property or an expression that contains the CheckBoxGroup state.
defaultValueNoNoRead Only
A literal value or an expression that is used to set the CheckBoxGroup's initial state.
disabledNoNoRead Only
A boolean value which if true will cause the CheckBoxGroup to be disabled.
labelStyleNoNoNo
The style of the label for each contained CheckBoxOption.
labelStyleClassNoNoNo
The style class of the label for each contained CheckBoxOption.
optionsDataSourceNoNoRead Only
An expression that is used to generate a set of dynamic CheckBoxOptions. If the underlying type is a com.bean.wlw.netui.tags.GroupOption the name, value, alt and accesskey may be individually set. If the underlying type is a Map the name and value may be set individually.
tagIdNoNoNo
The ID of this button used by the enclosing html tag to get the tag's real ID attribute for Javascript and focus purposes. The real ID attribute id is generated based upon this name.

See Also:
CheckBox, CheckBoxOption, 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 String[] on the Controller file:
        colors = new String[] {"Red", "Blue", "Green", "Yellow", "White", "Black"};
This automatically renders the appropriate set of checkbox options within the <checkBoxGroup>:
        <input type="checkbox" value="Red">Red</input>
        <input type="checkbox" value="Blue">Blue</input>
        <input type="checkbox" value="Green">Green</input>
        <input type="checkbox" value="Yellow">Yellow</input>
        <input type="checkbox" value="White">White</input>
        <input type="checkbox" value="Black">Black</input>
The defaultValue attribute may point to a String or a String[].
        defaultValue = new String ("Blue");
        defaultValue = new String[] {"Red", "Blue"};
In either case, the appropriate checkbox options will appear checked in the browser.
        <input type="checkbox" value="Red" checked="true">Red</input>
        <input type="checkbox" value="Blue" checked="true">Blue</input>
        <input type="checkbox" value="Green">Green</input>
        <input type="checkbox" value="Yellow">Yellow</input>
        <input type="checkbox" value="White">White</input>
        <input type="checkbox" value="Black">Black</input>

Code Samples

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/checkBoxGroup/ [BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/checkBoxOption/
Beadoc.see:
<netui:checkBoxGroup> Tag Sample, <netui:checkBoxOption> Tag Sample
Beadoc.tagdescription:
Handles data binding for a collection of CheckBoxOption tags.

Submitting Data

The <netui:checkBoxGroup> submits data in the form of a String[] object. For example, if the <netui:checkBoxGroup> submits data to a Form Bean field...

        <netui:checkBoxGroup 
                  dataSource="{actionForm.userSelections}"
                  optionsDataSource="{pageFlow.availableSelections}" />
...then the Form Bean field must be a String[] object...
      public static class SubmitForm extends FormData
      {
          private String[] userSelections;
      
          public void setUserSelections(String[] userSelections)
          {
              this.userSelections = userSelections;
          }
      
          public String[] getUserSelections()
          {
              return this.userSelections;
          }
      }

Dynamically Defined Checkboxes

You can dynamically define a set of checkboxes by pointing the optionsDataSource attribute at a String[] object. When the <netui:checkBoxGroup> is rendered in the browser, a corresponding set of checkboxes will be genereated from the String[] object.

For example, if you define a String[] object in the Controller file...

    public String[] availableOptions = {"option1", "option2", "option3"};
...and reference this String[] from the optionDataSource attribute...
        <netui:checkBoxGroup 
                  dataSource="{actionForm.userSelections}"
                  optionsDataSource="{pageFlow.availableSelections}" />
...then the appropriate checkboxes will be rendered in the browser.
      <input type="checkbox" value="option1">option1</input>
      <input type="checkbox" value="option2">option2</input>
      <input type="checkbox" value="option3">option3</input>
For checkboxes to be rendered, either the optionsDataSource attribute must be provided (and point to a String[] object) or the <netui:checkBoxGroup> must have children <netuiCheckBoxOption> tags.

Setting Default Options

The defaultValue attribute can be used to determine which checkboxs are checked when they are first rendered in the browser. The defaultValue attribute should point to a String, if only one checkbox should appear checked, or to a String[] object, if multiple checkboxes should appear checked.


Nested Class Summary
static class CheckBoxGroup.CheckboxGroupPrefixHandler
          The handler for naming and indexing the CheckBoxGroup.
 
Field Summary
static String CHECKBOXGROUP_KEY
           
protected  String labelStyle
          The style of the label for each contained CheckBoxOption.
protected  String labelStyleClass
          The style class of the label for each contained CheckBoxOption.
protected  String[] match
          The actual values we will match against, calculated in doStartTag().
protected  String saveBody
          The saved body content of this tag.
protected  boolean useDefault
           
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, 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, 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, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
CheckBoxGroup()
           
 
Method Summary
 int doAfterBody()
          Save the body content of the CheckBoxGroup.
 int doEndTag()
          Render the set of CheckBoxOptions.
 int doStartTag()
          Determine the set of matches for the CheckBoxGroup
protected  Object evaluateDefaultValue()
           
protected  Object evaluateOptionsDataSource()
          This method will evalute the optionsDataSource and return an object.
 String getDisabled()
          Returns the boolean value or expression indicating the disable state of the CheckBoxGroup.
 String getLabelStyle()
          Return the label style for each contained CheckBoxOption..
 String getLabelStyleClass()
          Return the label style class for each contained CheckBoxOption..
 String getStyle()
          Gets the style of the rendered html tag.
 String getStyleClass()
          Gets the style class of the rendered html tag.
 String getTagId()
          Return the ID of the checkbox group.
 String getTagName()
          Return the name of the Tag.
 boolean isMatched(String value)
          Checks whether the given value matches one of the CheckBoxGroup's selected CheckBoxOptions.
protected  void localRelease()
          Release any acquired resources.
 String qualifyDataSource()
           
 void setDisabled(String disabled)
          Set the disable state either with the literal "true" or "false" or with an expression.
 void setLabelStyle(String labelStyle)
          Set the label style for each contained CheckBoxOption..
 void setLabelStyleClass(String labelStyleClass)
          Set the label style class for each contained CheckBoxOption..
 void setStyle(String style)
          Sets the style of the rendered html tag.
 void setStyleClass(String styleClass)
          Sets the style class of the rendered html tag.
 void setTagId(String tagId)
          Set the ID of the checkbox group.
 
Methods inherited from class com.bea.wlw.netui.tags.OptionsDataSourceTag
getOptionsDataSource, setOptionsDataSource
 
Methods inherited from class com.bea.wlw.netui.tags.DefaultableDataSourceTag
getDefaultValue, setDefaultValue
 
Methods inherited from class com.bea.wlw.netui.tags.DataSourceTag
addNamingInterceptor, doNaming, evaluateDataSource, getDataSource, qualifyAttribute, removeNamingInterceptor, setDataSource
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

Field Detail

CHECKBOXGROUP_KEY

public static final String CHECKBOXGROUP_KEY
See Also:
Constant Field Values

match

protected String[] match
The actual values we will match against, calculated in doStartTag().

Exclude:

labelStyle

protected String labelStyle
The style of the label for each contained CheckBoxOption.

Exclude:

labelStyleClass

protected String labelStyleClass
The style class of the label for each contained CheckBoxOption.

Exclude:

saveBody

protected String saveBody
The saved body content of this tag.

Exclude:

useDefault

protected boolean useDefault
Exclude:
Constructor Detail

CheckBoxGroup

public CheckBoxGroup()
Method Detail

getTagName

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

Specified by:
getTagName in class AbstractBaseTag

evaluateDefaultValue

protected Object evaluateDefaultValue()
Overrides:
evaluateDefaultValue in class DefaultableDataSourceTag
Exclude:

evaluateOptionsDataSource

protected Object evaluateOptionsDataSource()
                                    throws javax.servlet.jsp.JspException
This method will evalute the optionsDataSource and return an object. If the object return from evaluating the expression results in a Map that is returned. Otherwise we will return an iterator. This routine will always return either a valid Iterator or Map.

Overrides:
evaluateOptionsDataSource in class OptionsDataSourceTag
Throws:
javax.servlet.jsp.JspException

getTagId

public String getTagId()
Return the ID of the checkbox group.

Returns:
the ID.

setTagId

public void setTagId(String tagId)
Set the ID of the checkbox group.

Parameters:
tagId - - the ID.
Beadoc.attributedescription:

String value. Sets the id (or name) attribute of the rendered HTML tag. Note that the real id attribute rendered in the browser may be changed by the application container (for example, Portal containers may change the rendered id value to ensure the uniqueness of id's on the page). In this case, the real id rendered in the browser may be looked up through the JavaScript function getNetuiTagName( tagId, tag ).

For example, assume that some tag's tagId attribute is set to foo.

    <netui:textBox tagId="foo" />

Then the following JavaScript function will return the real id attribute rendered in the browser:

    getNetuiTagName( "foo", this )

To get a <netui:form> element and all of its children elements in JavaScript, use the same JavaScript function getNetuiTagName( tagId, tag ). For example, assume that there is a <netui:form> whose tagId attribute is set to bar.

    <netui:form tagId="bar" >

Then the following JavaScript function will return the <netui:form> element and its children (packaged as an array).

    document[getNetuiTagName( "bar", this )]

To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following JavaScript expression.

    document[getNetuiTagName("bar", this)][getNetuiTagName("foo", this)].value

The second parameter ensures that the JavaScript function begins its search within the correct Portlet scope. Pass the JavaScript keyword this as the second parameter. For detailed information on using the function getNetuiTagName( tagId, tag ) see Using JavaScript in Page Flow and Portal Applications.

Beadoc.attributesyntaxvalue:
string_tagId
Beadoc.databindable:
false

getDisabled

public String getDisabled()
Returns the boolean value or expression indicating the disable state of the CheckBoxGroup.

Returns:
the disabled state (true or false) or an expression

setDisabled

public void setDisabled(String disabled)
Set the disable state either with the literal "true" or "false" or with an expression.

Parameters:
disabled - - true or false or an expression
Beadoc.attributedescription:
Boolean. If set to true, then the rendered set of check boxes will be disabled.
Beadoc.attributesyntaxvalue:
boolean_disabled
Beadoc.databindable:
false

getLabelStyle

public String getLabelStyle()
Return the label style for each contained CheckBoxOption..

Returns:
the label style

setLabelStyle

public void setLabelStyle(String labelStyle)
Set the label style for each contained CheckBoxOption..

Parameters:
labelStyle - - the label style
Beadoc.attributedescription:
The style of the label for each contained <netui:checkBoxOption> tag.
Beadoc.attributesyntaxvalue:
string_labelStyle
Beadoc.databindable:
false

getLabelStyleClass

public String getLabelStyleClass()
Return the label style class for each contained CheckBoxOption..

Returns:
the label style
Beadoc.attributedescription:
The class of the label for each contained <netui:checkBoxOption> tag.
Beadoc.attributesyntaxvalue:
string_labelClass
Beadoc.databindable:
false

setLabelStyleClass

public void setLabelStyleClass(String labelStyleClass)
Set the label style class for each contained CheckBoxOption..

Parameters:
labelStyleClass - - the label style

setStyle

public void setStyle(String style)
Sets the style of the rendered html tag.

Parameters:
style - - the html style.
Beadoc.attributedescription:
The style of the rendered HTML tag.
Beadoc.attributesyntaxvalue:
string_style
Beadoc.databindable:
false

getStyle

public String getStyle()
Gets the style of the rendered html tag.

Returns:
the style.

setStyleClass

public void setStyleClass(String styleClass)
Sets the style class of the rendered html tag.

Parameters:
styleClass - - the html style class.
Beadoc.attributedescription:
The class of the rendered HTML tag.
Beadoc.attributesyntaxvalue:
string_class
Beadoc.databindable:
false

getStyleClass

public String getStyleClass()
Gets the style class of the rendered html tag.

Returns:
the style class.

isMatched

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

Parameters:
value - Value to be compared

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Determine the set of matches for the CheckBoxGroup

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Save the body content of the CheckBoxGroup.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

doEndTag

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

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class OptionsDataSourceTag

qualifyDataSource

public String qualifyDataSource()
                         throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException
Exclude:

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.