org.loom.tags.core
Class AbstractOptionsTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by org.loom.tags.AbstractTag
          extended by org.loom.tags.AbstractDecoratedTag
              extended by org.loom.tags.AbstractHtmlTag
                  extended by org.loom.tags.AbstractFormFieldTag
                      extended by org.loom.tags.AbstractFormInputTag
                          extended by 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:


Nested Class Summary
static class AbstractOptionsTag.SortBy
           
 
Nested classes/interfaces inherited from class org.loom.tags.AbstractFormInputTag
AbstractFormInputTag.LabelPosition
 
Field Summary
 
Fields inherited from class org.loom.tags.AbstractFormInputTag
value
 
Fields inherited from class org.loom.tags.AbstractDecoratedTag
decorator
 
Fields inherited from class org.loom.tags.AbstractTag
expressionLanguageProxy, loomServletRequestFactory, out, repository, request, response
 
Constructor Summary
AbstractOptionsTag()
           
 
Method Summary
 void addOption(Option option)
           
 void addOption(java.lang.String value, java.lang.String label, java.lang.Boolean translateLabel)
           
 void calculateOptions()
          Returns the available options.
protected  Converter getConverter()
           
 java.util.List<Option> getNestedOptions()
           
protected  java.lang.Object getValueAsObject()
           
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
 boolean isTranslateLabels()
           
 void pullOptionsFromAttribute()
          If the options value is a list of Option instances, adds them
 java.lang.String renderAsText()
          Returns the label of the currently selected option, translated if necessary
 void setConverter(Converter converter)
           
 void setKeyProperty(java.lang.String keyProperty)
           
 void setLabelProperty(java.lang.String labelProperty)
           
 void setOptions(java.lang.Iterable<?> options)
          An Iterable with the available option values.
 void setOptionsComparatorClass(java.lang.String comparatorClass)
           
 void setSortBy(java.lang.String sortBy)
          The method to apply for sorting options.
 void setTranslateLabels(boolean translateLabels)
           
 
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.AbstractDecoratedTag
doTag, getDecorator, getDecoratorInstance, setDecorator
 
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
 
Methods inherited from interface org.loom.tags.HtmlTag
addCssClass, getCssBuilder
 
Methods inherited from interface org.loom.tags.LoomTag
getExtendedAttributes, getRequest, getScopedAttribute, setExtendedAttribute, setScopedAttribute
 

Constructor Detail

AbstractOptionsTag

public AbstractOptionsTag()
Method Detail

calculateOptions

public void calculateOptions()
                      throws javax.servlet.jsp.JspException,
                             java.io.IOException
Returns the available options. Supports any combination of:

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)