public class Button extends FormComponent<String> implements IFormSubmittingComponent
Within a form, you can nest Button components. Note that you don't have to do this to let the form work (a simple <input type="submit".. suffices), but if you want to have different kinds of submit behavior it might be a good idea to use Buttons.
The model property is used to set the "value" attribute. It will thus be the label of the button that shows up for end users. If you want the attribute to keep it's markup attribute value, don't provide a model, or let it return an empty string.
When you add a Wicket Button to a form, and that button is clicked, by default the button's onSubmit method is called first, and after that the form's onSubmit method is called. If you want to change this (e.g. you don't want to call the form's onSubmit method, or you want it called before the button's onSubmit method), you can override Form.delegateSubmit.
One other option you should know of is the 'defaultFormProcessing' property of Button components. When you set this to false (default is true), all validation and formupdating is bypassed and the onSubmit method of that button is called directly, and the onSubmit method of the parent form is not called. A common use for this is to create a cancel button.
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATORENABLE, 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 |
|---|
Button(String id)
Constructor without a model.
|
Button(String id,
IModel<String> model)
Constructor taking an model for rendering the 'label' of the button (the value attribute of
the input/button tag).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
getDefaultFormProcessing()
Gets the defaultFormProcessing property.
|
Form<?> |
getForm()
Override to not throw exception if there is no parent form.
|
protected String |
getOnClickScript()
Gets any script that should rendered as the "onclick" attribute of the button.
|
protected IModel<String> |
initModel()
Override of the default initModel behaviour.
|
void |
onAfterSubmit()
Override this method to provide special submit handling in a multi-button form.
|
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag.
|
void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Handle the container's body.
|
void |
onError()
Method that is invoked when form processing fails; for example, when there are validation
errors.
|
void |
onSubmit()
Override this method to provide special submit handling in a multi-button form.
|
Button |
setDefaultFormProcessing(boolean defaultFormProcessing)
Sets the defaultFormProcessing property.
|
void |
updateModel()
This method does nothing, as any model of a button is only used to display the button's label
(by setting it's markup attribute "value").
|
add, add, checkRequired, clearInput, convertInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getInput, getInputAsArray, getInputName, getModel, getModelObject, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDetach, onDisabled, onInvalid, onRequired, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrdergetLabelgetWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildrenadd, 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, getConverter, 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, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, 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, waitgetInputNamepublic Button(String id)
Component.Component(String)public Button(String id, IModel<String> model)
StringResourceModel for a
localized value.id - Component idmodel - The model property is used to set the "value" attribute. It will thus be
the label of the button that shows up for end users. If you want the attribute to
keep it's markup attribute value, don't provide a model, or let it return an empty
string.protected IModel<String> initModel()
initModel in class ComponentComponent.initModel()public Form<?> getForm()
getForm in interface IFormSubmittergetForm in class FormComponent<String>nullpublic final boolean getDefaultFormProcessing()
getDefaultFormProcessing in interface IFormSubmitterpublic final Button setDefaultFormProcessing(boolean defaultFormProcessing)
setDefaultFormProcessing in interface IFormSubmittingComponentdefaultFormProcessing - defaultFormProcessingpublic void updateModel()
updateModel in interface IFormModelUpdateListenerupdateModel in class FormComponent<String>FormComponent.updateModel()protected String getOnClickScript()
protected void onComponentTag(ComponentTag tag)
NOTE. For a <button> the value attribute is not rendered, markup needs to be added within the button to display the button's label.
onComponentTag in class FormComponent<String>tag - Tag to modifyComponent.onComponentTag(ComponentTag)public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
MarkupContaineronComponentTagBody in class MarkupContainermarkupStream - The markup streamopenTag - The open tag for the bodypublic void onError()
IFormSubmitteronError in interface IFormSubmitterpublic void onSubmit()
Form.onSubmit().onSubmit in interface IFormSubmitterpublic void onAfterSubmit()
Form.onSubmit().onAfterSubmit in interface IFormSubmitterCopyright © 2006–2021 Apache Software Foundation. All rights reserved.