org.loom.tags.core
Class InputCheckboxTag

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.InputCheckboxTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.DynamicAttributes, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag, FormInputTag, HtmlTag, LoomTag

@Tag(dynamicAttributes=true,
     bodyContent=EMPTY,
     example="<l:inputCheckbox name=\"mortgage.starred\"/>\n<c:forEach var=\"item\" items=\"${items}\" >\n\t<li><l:inputCheckbox name=\"selectedItems[${item.id}]\" />\n\t   Select item ${item.name}\n\t</li>\n</c:forEach>")
public class InputCheckboxTag
extends AbstractFormInputTag

HTML checkboxes.

For the normal use, value is ignored and the checkbox will render a "checked" attribute if the associated property is not null. When associating with a Set property, the name attribute should specify the value to get/set from the set as an index; if the Set contains the value, the checkbox will be checked, else it will not. On form submission, the Set will be populated with the elements that have been checked in the browser.

A hidden field will be generated after the checkbox to work around the fact that browsers do not submit unchecked checkboxes.


Nested Class Summary
 
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
InputCheckboxTag()
           
 
Method Summary
 void doTagImpl()
          The method that must be implemented by the child class
protected  boolean isChecked()
           
protected  boolean isMultiple()
          Return true if the checkbox is bound to a Set and false if not
 java.lang.String renderAsText()
          Returns the translation of the checkbox appended to the property path.
 boolean shouldRenderLabel()
          Multiple checkboxes set to renderAsText should not render a label
 
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
 
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, 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

InputCheckboxTag

public InputCheckboxTag()
Method Detail

doTagImpl

public void doTagImpl()
               throws javax.servlet.jsp.JspException,
                      java.io.IOException
Description copied from class: AbstractTag
The method that must be implemented by the child class

Specified by:
doTagImpl in class AbstractTag
Throws:
javax.servlet.jsp.JspException
java.io.IOException

isChecked

protected boolean isChecked()
Returns:
true if the checkbox is selected

isMultiple

protected boolean isMultiple()
Return true if the checkbox is bound to a Set and false if not


renderAsText

public java.lang.String renderAsText()
Returns the translation of the checkbox appended to the property path. if label is present it will be used as prefix inestead of name Example: if the name is mortgage.fixedIncome and the value is true, it will return the translation of "mortgage.fixedIcome.true" if label is "foobar"; will return the translation of "foobar.true"

Overrides:
renderAsText in class AbstractFormInputTag

shouldRenderLabel

public boolean shouldRenderLabel()
Multiple checkboxes set to renderAsText should not render a label

Overrides:
shouldRenderLabel in class AbstractFormInputTag
Returns:
true if the component or the form are set to renderLabel