wicket.markup.html.form
Class DropDownChoice

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.AbstractChoice
                      extended bywicket.markup.html.form.AbstractSingleSelectChoice
                          extended bywicket.markup.html.form.DropDownChoice
All Implemented Interfaces:
IOnChangeListener, IRequestListener, java.io.Serializable
Direct Known Subclasses:
ListChoice

public class DropDownChoice
extends wicket.markup.html.form.AbstractSingleSelectChoice
implements IOnChangeListener

A choice implemented as a dropdown menu/list. TODO elaborate with an example

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

Author:
Jonathan Locke, Eelco Hillenius, Johan Compagner
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
DropDownChoice(java.lang.String id)
           
DropDownChoice(java.lang.String id, java.util.Collection choices)
           
DropDownChoice(java.lang.String id, IChoiceList choices)
           
DropDownChoice(java.lang.String id, IModel model, java.util.Collection choices)
           
DropDownChoice(java.lang.String id, IModel model, IChoiceList choices)
           
 
Method Summary
protected  void detachModel()
          Detaches the model for this component if it is detachable.
 IChoiceList getChoices()
          Gets the list of choices.
protected  java.lang.String getDefaultChoice(java.lang.Object selected)
           
 java.lang.String getModelValue()
           
 boolean isNullValid()
          Is the null value a valid value?
protected  boolean isSelected(IChoice choice)
          Gets whether the given value represents the current selection.
protected  void onComponentTag(ComponentTag tag)
          Processes the component tag.
protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
          Handle the container's body.
 void onSelectionChanged()
          Called when a selection changes.
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 setChoices(IChoiceList choices)
          Sets the list of choices.
 void setModelValue(java.lang.String value)
          Sets the value for a form component.
 void setNullValid(boolean nullValid)
          Is the null value a valid value?
protected  boolean supportsPersistence()
           
protected  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, getValidationType, getValidators, getValue, inputAsInt, inputAsInt, inputAsIntArray, inputAsStringArray, invalid, isPersistent, isValid, isValidated, onInvalid, onModelChanged, onValid, setPersistent, valid, validate
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, onRender
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getMarkupStream, internalAdd, internalBeginRequest, internalEndRequest, iterator, remove, removeAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, debug, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getClassRelativePath, 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, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnBeginRequest, internalOnEndRequest, internalOnModelChanged, internalOnModelChanging, isAncestorOf, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onBeginRequest, onEndRequest, onModelChanging, onSessionAttach, redirectTo, remove, render, renderComponent, renderComponentTag, rendered, replaceComponentTagBody, sameRootModel, sameRootModel, setFlag, setModelObject, setRedirect, setRenderBodyOnly, setResponsePage, setShouldEscapeModelStrings, setVersioned, setVisible, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DropDownChoice

public DropDownChoice(java.lang.String id)
See Also:
AbstractChoice.AbstractChoice(String)

DropDownChoice

public DropDownChoice(java.lang.String id,
                      java.util.Collection choices)
See Also:
AbstractChoice.AbstractChoice(String, Collection)

DropDownChoice

public DropDownChoice(java.lang.String id,
                      IChoiceList choices)
See Also:
AbstractChoice.AbstractChoice(String, IChoiceList)

DropDownChoice

public DropDownChoice(java.lang.String id,
                      IModel model,
                      java.util.Collection choices)
See Also:
AbstractChoice.AbstractChoice(String, IModel, Collection)

DropDownChoice

public DropDownChoice(java.lang.String id,
                      IModel model,
                      IChoiceList choices)
See Also:
AbstractChoice.AbstractChoice(String, IModel, IChoiceList)
Method Detail

onSelectionChanged

public final void onSelectionChanged()
Called when a selection changes.

Specified by:
onSelectionChanged in interface IOnChangeListener

onComponentTag

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

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

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

getModelValue

public final java.lang.String getModelValue()
Overrides:
getModelValue in class FormComponent
Returns:
Value to return when model value is needed
See Also:
FormComponent.getModelValue()

isNullValid

public boolean isNullValid()
Is the null value a valid value?

Returns:
true when the null value is allowed.

setNullValid

public void setNullValid(boolean nullValid)
Is the null value a valid value?

Parameters:
nullValid - whether null is a valid value

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)

getDefaultChoice

protected java.lang.String getDefaultChoice(java.lang.Object selected)
Parameters:
selected - The object that's currently selected
Returns:
Any default choice, such as "Choose One", depending on the subclass
See Also:
AbstractChoice.getDefaultChoice(Object)

isSelected

protected boolean isSelected(IChoice choice)
Gets whether the given value represents the current selection.

Parameters:
choice - The choice to check
Returns:
Whether the given value represents the current selection

updateModel

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

See Also:
AbstractChoice.updateModel()

getChoices

public IChoiceList getChoices()
Gets the list of choices.

Returns:
The list of choices

setChoices

public final void setChoices(IChoiceList choices)
Sets the list of choices.

Parameters:
choices - the list of choices

detachModel

protected void detachModel()
Description copied from class: Component
Detaches the model for this component if it is detachable.

Overrides:
detachModel in class Component
See Also:
Component.detachModel()

onComponentTagBody

protected void onComponentTagBody(MarkupStream markupStream,
                                  ComponentTag openTag)
Handle the container's body.

Overrides:
onComponentTagBody in class MarkupContainer
Parameters:
markupStream - The markup stream
openTag - The open tag for the body
See Also:
Component.onComponentTagBody(MarkupStream, ComponentTag)

supportsPersistence

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


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