net.sourceforge.stripes.tag
Class InputRadioButtonTag

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
          extended by net.sourceforge.stripes.tag.InputTagSupport
              extended by net.sourceforge.stripes.tag.InputRadioButtonTag
All Implemented Interfaces:
BodyTag, DynamicAttributes, IterationTag, JspTag, Tag, TryCatchFinally

public class InputRadioButtonTag
extends InputTagSupport
implements BodyTag

Generates <input type="radio" value="foo"/> HTML tags based on the attribute set on the tag and the state of the form. Since a single radio button widget on a HTML page can have only a single value, the value tag attribute must be a Scalar object. The value will be converted to a String using the Stripes formatting system (with appropriate defaults), or by calling toString if an appropriate Formatter does not exist. Similarly since radio button sets can have only a single selected value at a time the checked attribute of the tag must also be a scalar value.

Radio buttons perform automatic (re-)population of state. They prefer, in order, the value in the HttpServletRequest, the value in the ActionBean and lastly the value set using checked="" on the page. If the value of the current radio button matches the checked value from the preferred source then the attribute checked="checked" will be written in the HTML tag.

The tag may include a body and if present the body is converted to a String and overrides the checked tag attribute.

Author:
Tim Fennell

Field Summary
 
Fields inherited from class net.sourceforge.stripes.tag.InputTagSupport
errorRenderer, fieldErrors
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
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
InputRadioButtonTag()
          Basic constructor that sets the input tag's type attribute to "radio".
 
Method Summary
 int doAfterBody()
          Does nothing.
 int doEndInputTag()
          Determines the state of the set of radio buttons and then writes the radio button to the output stream with checked="checked" or not as appropriate.
 void doInitBody()
          Does nothing.
 int doStartInputTag()
          Sets the input tag type to "radio".
 String getChecked()
          Returns the value set with setChecked().
 Object getValue()
          Returns the value set with setValue()
 Object getValueOnPage()
          Returns the body of the tag if it is present and not empty, otherwise returns the value of the 'checked' attribute.
 void setChecked(String checked)
          Sets the value amongst a set of radio buttons, that should be "checked" by default.
 void setValue(Object value)
          Sets the Object value of this individual checkbox.
 
Methods inherited from class net.sourceforge.stripes.tag.InputTagSupport
doCatch, doEndTag, doFinally, doStartTag, format, format, getActionBean, getDisabled, getFieldErrors, getFormatPattern, getFormatType, getLocalizedFieldName, getLocalizedFieldName, getName, getOverrideValueOrValues, getParentFormTag, getReadonly, getSingleOverrideValue, getSize, getValidationMetadata, hasErrors, isItemSelected, loadErrors, makeFocused, registerWithParentForm, setDisabled, setFocus, setFormatPattern, setFormatType, setName, setReadonly, setSize
 
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.BodyTag
setBodyContent
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
 

Constructor Detail

InputRadioButtonTag

public InputRadioButtonTag()
Basic constructor that sets the input tag's type attribute to "radio".

Method Detail

setChecked

public void setChecked(String checked)
Sets the value amongst a set of radio buttons, that should be "checked" by default.

Parameters:
checked - the default value for a set of radio buttons

getChecked

public String getChecked()
Returns the value set with setChecked().


setValue

public void setValue(Object value)
Sets the Object value of this individual checkbox.


getValue

public Object getValue()
Returns the value set with setValue()


doStartInputTag

public int doStartInputTag()
                    throws JspException
Sets the input tag type to "radio".

Specified by:
doStartInputTag in class InputTagSupport
Returns:
EVAL_BODY_BUFFERED in all cases.
Throws:
JspException

doInitBody

public void doInitBody()
                throws JspException
Does nothing.

Specified by:
doInitBody in interface BodyTag
Throws:
JspException

doAfterBody

public int doAfterBody()
                throws JspException
Does nothing.

Specified by:
doAfterBody in interface IterationTag
Returns:
SKIP_BODY in all cases.
Throws:
JspException

getValueOnPage

public Object getValueOnPage()
Returns the body of the tag if it is present and not empty, otherwise returns the value of the 'checked' attribute.

Overrides:
getValueOnPage in class InputTagSupport
Returns:
May return any of String[], Collection or Object

doEndInputTag

public int doEndInputTag()
                  throws JspException
Determines the state of the set of radio buttons and then writes the radio button to the output stream with checked="checked" or not as appropriate.

Specified by:
doEndInputTag in class InputTagSupport
Returns:
EVAL_PAGE in all cases.
Throws:
JspException - if the parent form tag cannot be found, or output cannot be written.


? Copyright 2005-2006, Stripes Development Team.