org.loom.tags.core
Class AbstractOptionsTag
java.lang.Object
javax.servlet.jsp.tagext.SimpleTagSupport
org.loom.tags.AbstractTag
org.loom.tags.AbstractDecoratedTag
org.loom.tags.AbstractHtmlTag
org.loom.tags.AbstractFormFieldTag
org.loom.tags.AbstractFormInputTag
org.loom.tags.core.AbstractOptionsTag
- All Implemented Interfaces:
- javax.servlet.jsp.tagext.DynamicAttributes, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag, FormInputTag, HtmlTag, LoomTag
- Direct Known Subclasses:
- InputRadioTag, InputSelectTag
public abstract class AbstractOptionsTag
- extends AbstractFormInputTag
Select or Radio field with nested options.
There are three ways of specifying nested options:
- Enumeration properties get their options lists automatically filled (though it can be overriden)
- They can be specified using the options attribute, which must be an Iterable with either
Option instances or any other class in which case the labelProperty and keyProperty will be
used to convert to Option objects
- Options can be defined as nested l: option tags. This can be combined with any of the other two methods
| Methods inherited from class org.loom.tags.AbstractFormInputTag |
getLabelCssClass, getLabelPosition, getRenderAsText, getRenderLabel, getTranslatedLabel, getValidators, getValue, hasError, initTag, isBound, isEscapeHTML, isTranslateLabel, printParentAttributes, setAddTranslatedName, setBound, setEscapeHTML, setLabelClass, setLabelPos, setLabelPosition, setRenderAsText, setRenderErrorDisplayComponent, setRenderLabel, setTranslateLabel, setValue, shouldRenderAsText, shouldRenderError, shouldRenderLabel |
| Methods inherited from class org.loom.tags.AbstractFormFieldTag |
getForm, getHelpLine, getLabel, getNormalizedName, getTabindex, isDisabled, setAlt, setDisabled, setForm, setHelpLine, setLabel, setName, setTabindex, setType |
| Methods inherited from class org.loom.tags.AbstractHtmlTag |
addCssClass, getAccesskey, getCssBuilder, getCssClass, getDir, getId, getLang, getName, getStyle, getTitle, getTranslatedTitle, identify, isCssProcessed, isIf, isTranslateTitle, renderTag, setAccesskey, setCssClass, setCssProcessed, setDir, setId, setIf, setLang, setStyle, setTitle, setTranslateTitle |
| Methods inherited from class org.loom.tags.AbstractTag |
createWriterWrapper, doBody, doBufferedBody, doTagImpl, endTag, evaluateExpression, getActionProperty, getAncestorWithClass, getBufferedBody, getExtendedAttributes, getMessagesRepository, getPageContext, getRequest, getResponse, getScopedAttribute, getWriter, removeScopedAttribute, setDynamicAttribute, setExtendedAttribute, setJspContext, setRequest, setResponse, setScopedAttribute, setWriter |
| Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport |
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setParent |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractOptionsTag
public AbstractOptionsTag()
calculateOptions
public void calculateOptions()
throws javax.servlet.jsp.JspException,
java.io.IOException
- Returns the available options. Supports any combination of:
- An options attribute, pointing to an Enum class
- An options attribute, listing its values separated by commas
- Nested <option> tags, those will be used
- If the target action property is an enumeration, the possible values
will be used
- Throws:
javax.servlet.jsp.JspException
java.io.IOException
getValueAsObject
protected java.lang.Object getValueAsObject()
- Returns:
- the value extracted from the nested property inside the action bean.
Note that this method does not consider validation or conversion errors. Consider using
getValue() instead.
getConverter
protected Converter getConverter()
- Returns:
- the
Converter to be used for converting each option to text
pullOptionsFromAttribute
public void pullOptionsFromAttribute()
- If the options value is a list of Option instances, adds them
guessOptionsFromEnumeration
protected void guessOptionsFromEnumeration(java.lang.Class<? extends java.lang.Enum<?>> enumerationClass)
- If the field is an Enum, translate the possible values to a list of
options
renderAsText
public java.lang.String renderAsText()
- Returns the label of the currently selected option, translated if
necessary
- Overrides:
renderAsText in class AbstractFormInputTag
addOption
public void addOption(java.lang.String value,
java.lang.String label,
java.lang.Boolean translateLabel)
addOption
public void addOption(Option option)
setTranslateLabels
public void setTranslateLabels(boolean translateLabels)
setOptions
@Attribute
public void setOptions(java.lang.Iterable<?> options)
- An Iterable with the available option values. If the Iterable contents are instances of
Option, they will be used as is. Otherwise, labelProperty and keyProperty will be used
to retrieve the labeland key properties, respectively. This attribute can be combined
with nested <option> tags
getNestedOptions
public java.util.List<Option> getNestedOptions()
isTranslateLabels
public boolean isTranslateLabels()
setLabelProperty
public void setLabelProperty(java.lang.String labelProperty)
setKeyProperty
public void setKeyProperty(java.lang.String keyProperty)
setOptionsComparatorClass
public void setOptionsComparatorClass(java.lang.String comparatorClass)
setSortBy
@Attribute
public void setSortBy(java.lang.String sortBy)
- The method to apply for sorting options. Possible values are "none", "value" and "label" (default)
setConverter
public void setConverter(Converter converter)