net.sourceforge.stripes.tag
Class InputSelectTag

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.InputSelectTag
All Implemented Interfaces:
BodyTag, DynamicAttributes, IterationTag, JspTag, Tag, TryCatchFinally

public class InputSelectTag
extends InputTagSupport
implements BodyTag

Coordinates with one or more other tags to produce a well formed HTML select tag with state repopulation. The select tag itself really only writes out the basic <select name="foo"> ... </select> piece of the structure, and provides mechanisms for child options to determine whether or not they should render themselves as selected.

Author:
Tim Fennell
See Also:
InputOptionTag, InputOptionsCollectionTag, InputOptionsEnumerationTag

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
InputSelectTag()
           
 
Method Summary
 int doAfterBody()
          Does nothing.
 int doEndInputTag()
          Writes out the close select tag (</select>).
 void doInitBody()
          Does nothing.
 int doStartInputTag()
          Writes out the opening <select name="foo"> tag.
 String getMultiple()
          Gets the HTML attribute "multiple".
 Object getSelectedValueOrValues()
          Returns the scalar value or Array or Collection of values that are to be selected in the select tag.
 Object getValue()
          Returns the String value set by the tag attribute on the JSP, or the override value set in the HttpRequest, or the override value bound to the ActionBean object in scope.
 boolean isOptionSelected(Object optionValue, boolean selectedOnPage)
          Checks to see if the option value should be rendered as selected or not.
 void release()
          Releases the discovered selected values and then calls super-release().
 void setMultiple(String multiple)
          If the text value passed in matches the empty string or (ignoring case) "multiple", or if the value can be converted to true by the BooleanTypeConverter then the attribute will be set to "multiple", otherwise the attribute will not be output.
 void setValue(Object value)
          Stores the value attribute in an instance variable since it is used to determine which options are checked.
 
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, getValueOnPage, 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, 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, setPageContext, setParent
 

Constructor Detail

InputSelectTag

public InputSelectTag()
Method Detail

setMultiple

public void setMultiple(String multiple)
If the text value passed in matches the empty string or (ignoring case) "multiple", or if the value can be converted to true by the BooleanTypeConverter then the attribute will be set to "multiple", otherwise the attribute will not be output.


getMultiple

public String getMultiple()
Gets the HTML attribute "multiple".


setValue

public void setValue(Object value)
Stores the value attribute in an instance variable since it is used to determine which options are checked.


getValue

public Object getValue()
Returns the String value set by the tag attribute on the JSP, or the override value set in the HttpRequest, or the override value bound to the ActionBean object in scope.

Returns:
Object one of String if the value comes from the tag on the JSP, String[] if the value(s) comes from the HttpServletRequest, or the type of the field on the ActionBean which could be Collection, Object[] or Object.

getSelectedValueOrValues

public Object getSelectedValueOrValues()
Returns the scalar value or Array or Collection of values that are to be selected in the select tag. This will either be the value returned by the PopulationStrategy, or the value supplied by the container to setValue().

Returns:
an Object, Object[] or Collection<Object> of values that are selected

isOptionSelected

public boolean isOptionSelected(Object optionValue,
                                boolean selectedOnPage)
                         throws StripesJspException
Checks to see if the option value should be rendered as selected or not. Consults with the override values on the form submission or backing form, if there is one. If there is no ActionBean object present, then return the values of selectedOnPage supplied by the option.

Parameters:
optionValue - the value of the option under consideration
selectedOnPage - true if the page contains selected=... and false otherwise
Throws:
StripesJspException

doStartInputTag

public int doStartInputTag()
                    throws JspException
Writes out the opening <select name="foo"> tag. Looks for values in the request and in the ActionBean if one is present, and caches those values so it can efficiently determine which child options should be selected or not.

Specified by:
doStartInputTag in class InputTagSupport
Returns:
EVAL_BODY_INCLUDE in all cases
Throws:
JspException - if the enclosing form tag cannot be found or output cannot be written

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

doEndInputTag

public int doEndInputTag()
                  throws JspException
Writes out the close select tag (</select>).

Specified by:
doEndInputTag in class InputTagSupport
Returns:
EVAL_PAGE in all cases
Throws:
JspException - if output cannot be written.

release

public void release()
Releases the discovered selected values and then calls super-release().

Specified by:
release in interface Tag
Overrides:
release in class HtmlTagSupport


? Copyright 2005-2006, Stripes Development Team.