wicket.markup.html.form
Class CheckBox

java.lang.Object
  extended bywicket.Component
      extended bywicket.MarkupContainer
          extended bywicket.markup.html.WebMarkupContainer
              extended bywicket.markup.html.form.FormComponent
                  extended bywicket.markup.html.form.CheckBox
All Implemented Interfaces:
IAjaxListener, IHeaderContributor, IOnChangeListener, IRequestListener, java.io.Serializable

public class CheckBox
extends FormComponent
implements IOnChangeListener

HTML checkbox input component.

Java:

 form.add(new CheckBox("bool"));
 
HTML:
 <input type="checkbox" wicket:id="bool" />
 

You can can extend this class and override method wantOnSelectionChangedNotifications() to force server roundtrips on each selection change.

Author:
Jonathan Locke
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class wicket.markup.html.form.FormComponent
FormComponent.IVisitor
 
Nested classes inherited from class wicket.Component
Component.ComponentModelChange, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, NO_INVALID_INPUT
 
Fields inherited from class wicket.Component
FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4
 
Constructor Summary
CheckBox(java.lang.String id)
           
CheckBox(java.lang.String id, IModel model)
           
 
Method Summary
protected  void onComponentTag(ComponentTag tag)
          Processes the component tag.
 void onSelectionChanged()
          Called when a new option is selected.
protected  void onSelectionChanged(java.lang.Object newSelection)
          Template method that can be overriden by clients that implement IOnChangeListener to be notified by onChange events of a select element.
 void setModelValue(java.lang.String value)
          Sets the value for a form component.
protected  boolean supportsPersistence()
           
 void updateModel()
          Updates this components' model from the request.
protected  boolean wantOnSelectionChangedNotifications()
          Whether this component's onSelectionChanged event handler should called using javascript if the selection changes.
 
Methods inherited from class wicket.markup.html.form.FormComponent
add, getForm, getInput, getInputName, getLabel, getModelValue, getValidationType, getValidators, getValue, inputAsInt, inputAsInt, inputAsIntArray, inputAsStringArray, invalid, isMultiPart, isPersistent, isValid, isValidated, onInvalid, onModelChanged, onValid, setLabel, setPersistent, valid, validate
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, onRender, renderHead
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, internalAdd, internalBeginRequest, internalEndRequest, iterator, iterator, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, add, addStateChange, checkComponentTag, checkComponentTagAttribute, debug, detachModel, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getAjaxHandlers, getApplication, getApplicationPages, getApplicationSettings, getClassRelativePath, getComparator, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getId, getLocale, getLocalizer, getModel, getModelObject, getModelObjectAsString, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResource, getResponse, getSession, getString, getString, getString, getStyle, getVariation, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnBeginRequest, internalOnEndRequest, internalOnModelChanged, internalOnModelChanging, isAncestorOf, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onBeginRequest, onEndRequest, onModelChanging, onRequest, onSessionAttach, redirectTo, remove, render, renderComponent, renderComponentTag, rendered, replaceComponentTagBody, sameRootModel, sameRootModel, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setModelObject, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CheckBox

public CheckBox(java.lang.String id)
See Also:
Component.Component(String)

CheckBox

public CheckBox(java.lang.String id,
                IModel model)
See Also:
Component.Component(String, IModel)
Method Detail

setModelValue

public final void setModelValue(java.lang.String value)
Description copied from class: FormComponent
Sets the value for a form component.

Overrides:
setModelValue in class FormComponent
Parameters:
value - The value
See Also:
FormComponent.setModelValue(java.lang.String)

onSelectionChanged

public void onSelectionChanged()
Description copied from interface: IOnChangeListener
Called when a new option is selected.

Specified by:
onSelectionChanged in interface IOnChangeListener
See Also:
IOnChangeListener.onSelectionChanged()

onSelectionChanged

protected void onSelectionChanged(java.lang.Object newSelection)
Template method that can be overriden by clients that implement IOnChangeListener to be notified by onChange events of a select element. This method does nothing by default.

Called when a option is selected of a dropdown list that wants to be notified of this event. This method is to be implemented by clients that want to be notified of selection events.

Parameters:
newSelection - The newly selected object of the backing model NOTE this is the same as you would get by calling getModelObject() if the new selection were current

wantOnSelectionChangedNotifications

protected boolean wantOnSelectionChangedNotifications()
Whether this component's onSelectionChanged event handler should called using javascript if the selection changes. If true, a roundtrip will be generated with each selection change, resulting in the model being updated (of just this component) and onSelectionChanged being called. This method returns false by default.

Returns:
True if this component's onSelectionChanged event handler should called using javascript if the selection changes

onComponentTag

protected final void onComponentTag(ComponentTag tag)
Processes the component tag.

Overrides:
onComponentTag in class FormComponent
Parameters:
tag - Tag to modify
See Also:
Component.onComponentTag(ComponentTag)

supportsPersistence

protected final boolean supportsPersistence()
Overrides:
supportsPersistence in class FormComponent
Returns:
True if this type of FormComponent can be persisted.
See Also:
FormComponent.supportsPersistence()

updateModel

public void updateModel()
Updates this components' model from the request.

Specified by:
updateModel in class FormComponent
See Also:
FormComponent.updateModel()


Copyright © 2004-2006 Wicket developers. All Rights Reserved.