FileDocCategorySizeDatePackage
Checkbox.javaAPI DocExample2967Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

Checkbox

public class Checkbox extends UIBean
Renders an HTML input element of type checkbox, populated by the specified property from the ValueStack.

Examples


JSP:
<s:checkbox label="checkbox test" name="checkboxField1" value="aBoolean" fieldValue="true"/>

Velocity:
#tag( Checkbox "label=checkbox test" "name=checkboxField1" "value=aBoolean" )

Resulting HTML (simple template, aBoolean == true):
<input type="checkbox" name="checkboxField1" value="true" checked="checked" />


Fields Summary
public static final String
TEMPLATE
protected String
fieldValue
Constructors Summary
public Checkbox(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)


           
        super(stack, request, response);
    
Methods Summary
protected voidevaluateExtraParams()

        if (fieldValue != null) {
            addParameter("fieldValue", findString(fieldValue));
        } else {
            addParameter("fieldValue", "true");
        }
    
protected java.lang.StringgetDefaultTemplate()

        return TEMPLATE;
    
protected java.lang.ClassgetValueClassType()

        return Boolean.class; // for checkboxes, everything needs to end up as a Boolean
    
public voidsetFieldValue(java.lang.String fieldValue)

        this.fieldValue = fieldValue;