T
- public class AjaxEditableLabel<T> extends Panel implements IGenericComponent<T>
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> 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
|
IModel<T> |
getModel()
Typesafe getter for the model
|
T |
getModelObject()
Typesafe getter for the model's object
|
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()
Called just before a component is rendered only if the component is visible.
|
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)
Sets the given model.
|
AjaxEditableLabel<T> |
setLabel(IModel<String> labelModel)
The value will be made available to the validator property by means of ${label}.
|
void |
setModel(IModel<T> model)
Typesafe setter for the model
|
void |
setModelObject(T object)
Typesafe setter for the model object
|
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 boolean |
shouldTrimInput()
Determines whether or not the textfield should trim its input prior to processing it.
|
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, newMarkupSourcingStrategy
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, 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, visitChildren
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, 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, isRendering, 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, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dequeue, newDequeueContext
public 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> IConverter<C> getConverter(Class<C> type)
getConverter
in interface IConverterLocator
getConverter
in class Component
C
- The object to convert from and to Stringtype
- The type to convert topublic final AjaxEditableLabel<T> setLabel(IModel<String> labelModel)
labelModel
- public final AjaxEditableLabel<T> setDefaultModel(IModel<?> model)
Component
WARNING: DO NOT OVERRIDE THIS METHOD UNLESS YOU HAVE A VERY GOOD REASON FOR IT. OVERRIDING THIS MIGHT OPEN UP SECURITY LEAKS AND BREAK BACK-BUTTON SUPPORT.
setDefaultModel
in class MarkupContainer
model
- The modelComponent.setDefaultModel(org.apache.wicket.model.IModel)
public IModel<T> getModel()
IGenericComponent
getModel
in interface IGenericComponent<T>
public T getModelObject()
IGenericComponent
getModelObject
in interface IGenericComponent<T>
public void setModel(IModel<T> model)
IGenericComponent
setModel
in interface IGenericComponent<T>
model
- the new modelpublic void setModelObject(T object)
IGenericComponent
setModelObject
in interface IGenericComponent<T>
object
- the new model objectpublic 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 boolean shouldTrimInput()
true
protected 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()
Component
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading Component.onBeforeRender()
call to its
children it is strongly recommended that super call is made at the end of the override.
onBeforeRender
in class Component
MarkupContainer.addOrReplace(Component...)
protected 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 Component
protected void onModelChanging()
onModelChanging
in class Component
Copyright © 2006–2021 Apache Software Foundation. All rights reserved.