
com.opensymphony.webwork.components.Checkbox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webwork Show documentation
Show all versions of webwork Show documentation
WebWork is a Java web-application development framework.
It is built specifically with developer productivity and
code simplicity in mind, providing robust support for building
reusable UI templates, such as form controls, UI themes,
internationalization, dynamic form parameter mapping to JavaBeans,
robust client and server side validation, and much more.
The newest version!
package com.opensymphony.webwork.components;
import com.opensymphony.xwork.util.OgnlValueStack;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* Renders an HTML input element of type checkbox, populated by the specified property from the OgnlValueStack.
*
*
* Examples
*
*
*
* JSP:
* <ww: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" />
*
*
*
*
* @author Patrick Lightbody
* @author Rene Gielen
* @version $Revision: 2468 $
* @since 2.2
*
* @ww.tag name="checkbox" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.CheckboxTag"
* description="Render a checkbox input field"
*/
public class Checkbox extends UIBean {
final public static String TEMPLATE = "checkbox";
protected String fieldValue;
public Checkbox(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
}
protected String getDefaultTemplate() {
return TEMPLATE;
}
protected void evaluateExtraParams() {
if (fieldValue != null) {
addParameter("fieldValue", findString(fieldValue));
} else {
addParameter("fieldValue", "true");
}
}
protected Class getValueClassType() {
return Boolean.class; // for checkboxes, everything needs to end up as a Boolean
}
/**
* The actual HTML value attribute of the checkbox.
* @ww.tagattribute required="false" default="'true'"
*/
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy