org.apache.wicket.extensions.ajax.markup.html
Class AjaxEditableLabel

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
                  extended by org.apache.wicket.markup.html.panel.Panel
                      extended by org.apache.wicket.extensions.ajax.markup.html.AjaxEditableLabel
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IConverterLocator, org.apache.wicket.markup.html.IHeaderPartContainerProvider
Direct Known Subclasses:
AjaxEditableChoiceLabel, AjaxEditableMultiLineLabel

public class AjaxEditableLabel
extends org.apache.wicket.markup.html.panel.Panel

An implementation of ajaxified edit-in-place component using a TextField as it's editor.

There are several methods that can be overridden for customization.

Author:
Igor Vaynberg (ivaynberg), Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
protected  class AjaxEditableLabel.EditorAjaxBehavior
           
protected  class AjaxEditableLabel.LabelAjaxBehavior
           
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
org.apache.wicket.Component.ComponentModelChange, org.apache.wicket.Component.EnabledChange, org.apache.wicket.Component.IVisitor, org.apache.wicket.Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Constructor Summary
AjaxEditableLabel(java.lang.String id)
          Constructor
AjaxEditableLabel(java.lang.String id, org.apache.wicket.model.IModel model)
          Constructor
 
Method Summary
 AjaxEditableLabel add(org.apache.wicket.validation.IValidator validator)
          Adds a validator to this form component.
protected  java.lang.String defaultNullLabel()
          Override this to display a different value when the model object is null.
 org.apache.wicket.util.convert.IConverter getConverter(java.lang.Class type)
          Implementation that returns null by default (panels don't typically need converters anyway).
protected  org.apache.wicket.markup.html.form.FormComponent getEditor()
          Gets the editor component.
protected  org.apache.wicket.Component getLabel()
          Gets the label component.
protected  java.lang.String getLabelAjaxEvent()
          By default this returns "onclick" uses can overwrite this on which event the label behavior should be triggered
protected  org.apache.wicket.markup.html.form.FormComponent newEditor(org.apache.wicket.MarkupContainer parent, java.lang.String componentId, org.apache.wicket.model.IModel model)
          Create a new form component instance to serve as editor.
protected  org.apache.wicket.Component newLabel(org.apache.wicket.MarkupContainer parent, java.lang.String componentId, org.apache.wicket.model.IModel model)
          Create a new form component instance to serve as label.
protected  void onBeforeRender()
           
protected  void onCancel(org.apache.wicket.ajax.AjaxRequestTarget target)
          Invoked when the label is in edit mode, and received a cancel event.
protected  void onEdit(org.apache.wicket.ajax.AjaxRequestTarget target)
          Called when the label is clicked and the component is put in edit mode.
protected  void onError(org.apache.wicket.ajax.AjaxRequestTarget target)
          Invoked when the label is in edit mode, received a new input, but that input didn't validate
protected  void onSubmit(org.apache.wicket.ajax.AjaxRequestTarget target)
          Invoked when the editor was successfully updated.
 AjaxEditableLabel setLabel(org.apache.wicket.model.IModel labelModel)
          The value will be made available to the validator property by means of ${label}.
 org.apache.wicket.Component setModel(org.apache.wicket.model.IModel model)
           
 AjaxEditableLabel setRequired(boolean required)
          Sets the required flag
 AjaxEditableLabel setType(java.lang.Class type)
          Sets the type that will be used when updating the model for this component.
 
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
onComponentTag, onComponentTagBody, renderHead
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
newHeaderPartContainer, renderHeadFromAssociatedMarkupFile
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getClassRelativePath, getComponentBorder, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getModelObjectAsString, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeginRequest, onDetach, onEndRequest, onModelChanged, onModelChanging, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMetaData, setModelObject, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AjaxEditableLabel

public AjaxEditableLabel(java.lang.String id)
Constructor

Parameters:
id -

AjaxEditableLabel

public AjaxEditableLabel(java.lang.String id,
                         org.apache.wicket.model.IModel model)
Constructor

Parameters:
id -
model -
Method Detail

add

public final AjaxEditableLabel add(org.apache.wicket.validation.IValidator validator)
Adds a validator to this form component. A model must be available for this component before Validators can be added. Either add this Component to its parent (already having a Model), or provide one before this call via constructor AjaxEditableLabel(String,IModel) or setModel(IModel).

Parameters:
validator - The validator
Returns:
This

getConverter

public org.apache.wicket.util.convert.IConverter getConverter(java.lang.Class type)
Implementation that returns null by default (panels don't typically need converters anyway). This is used by the embedded default instances of label and form field to determine whether they should use a converter like they normally would (when this method returns null), or whether they should use a custom converter (when this method is overridden and returns not null).

Specified by:
getConverter in interface org.apache.wicket.IConverterLocator
Overrides:
getConverter in class org.apache.wicket.Component
See Also:
Component.getConverter(java.lang.Class)

setLabel

public final AjaxEditableLabel setLabel(org.apache.wicket.model.IModel labelModel)
The value will be made available to the validator property by means of ${label}. It does not have any specific meaning to FormComponent itself.

Parameters:
labelModel -
Returns:
this for chaining

setModel

public final org.apache.wicket.Component setModel(org.apache.wicket.model.IModel model)
Overrides:
setModel in class org.apache.wicket.MarkupContainer
See Also:
MarkupContainer.setModel(org.apache.wicket.model.IModel)

setRequired

public final AjaxEditableLabel setRequired(boolean required)
Sets the required flag

Parameters:
required -
Returns:
this for chaining

setType

public final AjaxEditableLabel setType(java.lang.Class type)
Sets the type that will be used when updating the model for this component. If no type is specified String type is assumed.

Parameters:
type -
Returns:
this for chaining

newEditor

protected org.apache.wicket.markup.html.form.FormComponent newEditor(org.apache.wicket.MarkupContainer parent,
                                                                     java.lang.String componentId,
                                                                     org.apache.wicket.model.IModel model)
Create a new form component instance to serve as editor.

Parameters:
parent - The parent component
componentId - Id that should be used by the component
model - The model
Returns:
The editor

newLabel

protected org.apache.wicket.Component newLabel(org.apache.wicket.MarkupContainer parent,
                                               java.lang.String componentId,
                                               org.apache.wicket.model.IModel model)
Create a new form component instance to serve as label.

Parameters:
parent - The parent component
componentId - Id that should be used by the component
model - The model
Returns:
The editor

getLabelAjaxEvent

protected java.lang.String getLabelAjaxEvent()
By default this returns "onclick" uses can overwrite this on which event the label behavior should be triggered

Returns:
The event name

getEditor

protected final org.apache.wicket.markup.html.form.FormComponent getEditor()
Gets the editor component.

Returns:
The editor component

getLabel

protected final org.apache.wicket.Component getLabel()
Gets the label component.

Returns:
The label component

onBeforeRender

protected void onBeforeRender()
Overrides:
onBeforeRender in class org.apache.wicket.Component
See Also:
Component.onBeforeRender()

onCancel

protected void onCancel(org.apache.wicket.ajax.AjaxRequestTarget target)
Invoked when the label is in edit mode, and received a cancel event. Typically, nothing should be done here.

Parameters:
target - the ajax request target

onEdit

protected void onEdit(org.apache.wicket.ajax.AjaxRequestTarget target)
Called when the label is clicked and the component is put in edit mode.

Parameters:
target - Ajax target

onError

protected void onError(org.apache.wicket.ajax.AjaxRequestTarget target)
Invoked when the label is in edit mode, received a new input, but that input didn't validate

Parameters:
target - the ajax request target

onSubmit

protected void onSubmit(org.apache.wicket.ajax.AjaxRequestTarget target)
Invoked when the editor was successfully updated. Use this method e.g. to persist the changed value. This implementation displays the label and clears any window status that might have been set in onError.

Parameters:
target - The ajax request target

defaultNullLabel

protected java.lang.String defaultNullLabel()
Override this to display a different value when the model object is null. Default is ...

Returns:
The string which should be displayed when the model object is null.


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.