|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup
org.apache.wicket.markup.html.panel.Panel
org.apache.wicket.extensions.ajax.markup.html.AjaxEditableLabel<T>
T
- public class AjaxEditableLabel<T>
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.
onEdit(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(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(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(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.
Nested Class Summary | |
---|---|
protected class |
AjaxEditableLabel.EditorAjaxBehavior
|
protected class |
AjaxEditableLabel.LabelAjaxBehavior
|
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange |
Field Summary |
---|
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
AjaxEditableLabel(String id)
Constructor |
|
AjaxEditableLabel(String id,
IModel<T> model)
Constructor |
Method Summary | |
---|---|
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. |
IConverter |
getConverter(Class<?> type)
Implementation that returns null by default (panels don't typically need converters anyway). |
protected FormComponent<T> |
getEditor()
Gets the editor component. |
protected WebComponent |
getLabel()
Gets the label component. |
protected String |
getLabelAjaxEvent()
By default this returns "onclick" uses 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 WebComponent |
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. |
protected void |
onCancel(AjaxRequestTarget target)
Invoked when the label is in edit mode, and received a cancel event. |
protected 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}. |
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. |
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, getWebRequest |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onAfterRenderChildren, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AjaxEditableLabel(String id)
id
- public AjaxEditableLabel(String id, IModel<T> model)
id
- model
- Method Detail |
---|
public final AjaxEditableLabel<T> add(IValidator<T> validator)
AjaxEditableLabel(String,IModel)
or
setDefaultModel(IModel)
.
validator
- The validator
public IConverter getConverter(Class<?> type)
getConverter
in interface IConverterLocator
getConverter
in class Component
type
- The type to convert to
Component.getConverter(java.lang.Class)
public 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 model
MarkupContainer.setDefaultModel(org.apache.wicket.model.IModel)
public 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 model
protected WebComponent newLabel(MarkupContainer parent, String componentId, IModel<T> model)
parent
- The parent componentcomponentId
- Id that should be used by the componentmodel
- The model
protected String getLabelAjaxEvent()
protected final FormComponent<T> getEditor()
protected final WebComponent 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
Component.onBeforeRender()
protected void onCancel(AjaxRequestTarget target)
target
- the ajax request targetprotected 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
Component.onModelChanged()
protected void onModelChanging()
onModelChanging
in class Component
Component.onModelChanging()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |