T - public class AjaxEditableLabel<T> extends Panel
TextField as it's editor.
There are several methods that can be overridden for customization.
onEdit(org.apache.wicket.ajax.AjaxRequestTarget) is called when the label is clicked
and the editor is to be displayed. The default implementation switches the label for the editor
and places the caret at the end of the text.onSubmit(org.apache.wicket.ajax.AjaxRequestTarget) is called when in edit mode, the
user submitted new content, that content validated well, and the model value successfully
updated. This implementation also clears any window.status set.onError(org.apache.wicket.ajax.AjaxRequestTarget) is called when in edit mode, the
user submitted new content, but that content did not validate. Get the current input by calling
FormComponent.getInput() on getEditor(), and the error message by calling:
String errorMessage = editor.getFeedbackMessage().getMessage();The default implementation of this method displays the error message in
window.status, redisplays the editor, selects the editor's content and sets the
focus on it.
onCancel(org.apache.wicket.ajax.AjaxRequestTarget) is called when in edit mode, the
user choose not to submit the contents (he/she pressed escape). The default implementation
displays the label again without any further action.| Modifier and Type | Class and Description |
|---|---|
protected class |
AjaxEditableLabel.EditorAjaxBehavior |
protected class |
AjaxEditableLabel.LabelAjaxBehavior |
ENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING| Constructor and Description |
|---|
AjaxEditableLabel(String id)
Constructor
|
AjaxEditableLabel(String id,
IModel<T> model)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
AjaxEditableLabel<T> |
add(IValidator<T> validator)
Adds a validator to this form component.
|
protected String |
defaultNullLabel()
Override this to display a different value when the model object is null.
|
<C> org.apache.wicket.util.convert.IConverter<C> |
getConverter(Class<C> type)
Implementation that returns null by default (panels don't typically need converters anyway).
|
protected FormComponent<T> |
getEditor()
Gets the editor component.
|
protected Component |
getLabel()
Gets the label component.
|
protected String |
getLabelAjaxEvent()
By default this returns "click", users can overwrite this on which event the label behavior
should be triggered
|
protected FormComponent<T> |
newEditor(MarkupContainer parent,
String componentId,
IModel<T> model)
Create a new form component instance to serve as editor.
|
protected Component |
newLabel(MarkupContainer parent,
String componentId,
IModel<T> model)
Create a new form component instance to serve as label.
|
protected void |
onBeforeRender() |
protected void |
onCancel(AjaxRequestTarget target)
Invoked when the label is in edit mode, and received a cancel event.
|
void |
onEdit(AjaxRequestTarget target)
Called when the label is clicked and the component is put in edit mode.
|
protected void |
onError(AjaxRequestTarget target)
Invoked when the label is in edit mode, received a new input, but that input didn't validate
|
protected void |
onModelChanged()
Dummy override to fix WICKET-1239
|
protected void |
onModelChanging()
Dummy override to fix WICKET-1239
|
protected void |
onSubmit(AjaxRequestTarget target)
Invoked when the editor was successfully updated.
|
AjaxEditableLabel<T> |
setDefaultModel(IModel<?> model) |
AjaxEditableLabel<T> |
setLabel(IModel<String> labelModel)
The value will be made available to the validator property by means of ${label}.
|
AjaxEditableLabel<T> |
setRequired(boolean required)
Sets the required flag
|
AjaxEditableLabel<T> |
setType(Class<?> type)
Sets the type that will be used when updating the model for this component.
|
protected void |
updateEditorAjaxAttributes(AjaxRequestAttributes attributes)
Gives a chance to the specializations to modify the Ajax attributes for the request when this
component switches from a label to an editor.
|
protected void |
updateLabelAjaxAttributes(AjaxRequestAttributes attributes)
Gives a chance to the specializations to modify the Ajax attributes for the request when this
component switches from an editor to a label.
|
getRegionMarkup, newMarkupSourcingStrategygetWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onDetach, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildrenadd, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onComponentTag, onConfigure, onEvent, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdequeue, newDequeueContextpublic AjaxEditableLabel(String id)
id - protected void updateLabelAjaxAttributes(AjaxRequestAttributes attributes)
attributes - The Ajax attributes to modifyprotected void updateEditorAjaxAttributes(AjaxRequestAttributes attributes)
attributes - The Ajax attributes to modifypublic final AjaxEditableLabel<T> add(IValidator<T> validator)
AjaxEditableLabel(String,IModel) or
setDefaultModel(IModel).validator - The validatorpublic <C> org.apache.wicket.util.convert.IConverter<C> getConverter(Class<C> type)
getConverter in interface IConverterLocatorgetConverter in class Componentpublic final AjaxEditableLabel<T> setLabel(IModel<String> labelModel)
labelModel - public final AjaxEditableLabel<T> setDefaultModel(IModel<?> model)
setDefaultModel in class MarkupContainerpublic final AjaxEditableLabel<T> setRequired(boolean required)
required - public final AjaxEditableLabel<T> setType(Class<?> type)
type - protected FormComponent<T> newEditor(MarkupContainer parent, String componentId, IModel<T> model)
parent - The parent componentcomponentId - Id that should be used by the componentmodel - The modelprotected Component newLabel(MarkupContainer parent, String componentId, IModel<T> model)
parent - The parent componentcomponentId - Id that should be used by the componentmodel - The modelprotected String getLabelAjaxEvent()
protected final FormComponent<T> getEditor()
protected final Component getLabel()
protected void onBeforeRender()
onBeforeRender in class Componentprotected void onCancel(AjaxRequestTarget target)
target - the ajax request targetpublic void onEdit(AjaxRequestTarget target)
target - Ajax targetprotected void onError(AjaxRequestTarget target)
target - the ajax request targetprotected void onSubmit(AjaxRequestTarget target)
target - The ajax request targetprotected String defaultNullLabel()
...protected void onModelChanged()
onModelChanged in class Componentprotected void onModelChanging()
onModelChanging in class ComponentCopyright © 2006–2015 Apache Software Foundation. All rights reserved.