org.apache.wicket.markup.html.form
Class Form<T>

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.form.Form<T>
Type Parameters:
T - The model object type
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator, IRequestListener, IFormSubmitListener, IHeaderContributor
Direct Known Subclasses:
EditBook.EditBookForm, FilterForm, GuestBook.CommentForm, GuestBook.CommentForm, SignIn.SignInForm, SignInPanel.SignInForm, StatelessForm

public class Form<T>
extends WebMarkupContainer
implements IFormSubmitListener, IHeaderContributor

Base class for forms. To implement a form, subclass this class, add FormComponents (such as CheckBoxes, ListChoices or TextFields) to the form. You can nest multiple IFormSubmittingComponents if you want to vary submit behavior. However, it is not necessary to use any of Wicket's classes (such as Button or SubmitLink), just putting e.g. <input type="submit" value="go"> suffices.

By default, the processing of a form works like this:

  • The submitting component is looked up. An submitting IFormSubmittingComponent (such as a button) is nested in this form (is a child component) and was clicked by the user. If an IFormSubmittingComponent was found, and it has the defaultFormProcessing field set to false (default is true), it's onSubmit method will be called right away, thus no validition is done, and things like updating form component models that would normally be done are skipped. In that respect, nesting an IFormSubmittingComponent with the defaultFormProcessing field set to false has the same effect as nesting a normal link. If you want you can call validate() to execute form validation, hasError() to find out whether validate() resulted in validation errors, and updateFormComponentModels() to update the models of nested form components.
  • When no submitting IFormSubmittingComponent with defaultFormProcessing set to false was found, this form is processed (method process()). Now, two possible paths exist:
  • Form for handling (file) uploads with multipart requests is supported by calling setMultiPart(true) ( although wicket will try to automatically detect this for you ). Use this with FileUploadField components. You can attach multiple FileUploadField components for multiple file uploads.

    In case of an upload error two resource keys are available to specify error messages: uploadTooLarge and uploadFailed ie in [page].properties [form-id].uploadTooLarge=You have uploaded a file that is over the allowed limit of 2Mb

    If you want to have multiple IFormSubmittingComponents which submit the same form, simply put two or more IFormSubmittingComponents somewhere in the hierarchy of components that are children of the form.

    To get form components to persist their values for users via cookies, simply call setPersistent(true) on each component.

    Forms can be nested. You can put a form in another form. Since HTML doesn't allow nested <form> tags, the inner forms will be rendered using the <div> tag. You have to submit the inner forms using explicit components (like Button or SubmitLink), you can't rely on implicit submit behavior (by using just <input type="submit"> that is not attached to a component).

    When a nested form is submitted, the user entered values in outer (parent) forms are preserved and only the fields in the submitted form are validated.

    Author:
    Jonathan Locke, Juergen Donnerstag, Eelco Hillenius, Cameron Braid, Johan Compagner, Igor Vaynberg (ivaynberg), David Leangen
    See Also:
    Serialized Form

    Nested Class Summary
    static class Form.ValidationVisitor
              Visitor used for validation
     
    Nested classes/interfaces inherited from class org.apache.wicket.Component
    Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange
     
    Field Summary
    static String METHOD_GET
              Constant for specifying how a form is submitted, in this case using get.
    static String METHOD_POST
              Constant for specifying how a form is submitted, in this case using post.
     
    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, PARENT_PATH, PATH_SEPARATOR, RENDER
     
    Fields inherited from interface org.apache.wicket.markup.html.form.IFormSubmitListener
    INTERFACE
     
    Constructor Summary
    Form(String id)
              Constructs a form with no validation.
    Form(String id, IModel<T> model)
               
     
    Method Summary
     void add(IFormValidator validator)
              Adds a form validator to the form.
    protected  void appendDefaultButtonField(MarkupStream markupStream, ComponentTag openTag)
              If a default IFormSubmittingComponent was set on this form, this method will be called to render an extra field with an invisible style so that pressing enter in one of the textfields will do a form submit using this component.
    protected  void beforeUpdateFormComponentModels()
              Template method to allow clients to do any processing (like recording the current model so that, in case onSubmit does further validation, the model can be rolled back) before the actual updating of form component models is done.
    protected  void callOnError()
              Calls onError on this Form and any enabled and visible nested form, if the respective Form actually has errors.
     void clearInput()
              Clears the input from the form's nested children of type FormComponent.
    protected  void delegateSubmit(IFormSubmittingComponent submittingComponent)
              Called (by the default implementation of 'process') when all fields validated, the form was updated and it's data was allowed to be persisted.
    protected  boolean encodeUrlInHiddenFields()
               
     void error(String error, Map<String,Object> args)
              Registers an error feedback message for this component
    static Form<?> findForm(Component component)
               
     IFormSubmittingComponent findSubmittingButton()
              Gets the IFormSubmittingComponent which submitted this form.
     IFormSubmittingComponent getDefaultButton()
              Gets the default IFormSubmittingComponent.
     Collection<IFormValidator> getFormValidators()
              Gets all IFormValidators added to this form
     String getHiddenFieldId()
              Returns the HiddenFieldId which will be used as the name and id property of the hiddenfield that is generated for event dispatches.
    protected  String getInputNamePrefix()
              Allows to customize input names of form components inside this form.
    protected  String getJavascriptId()
              Deprecated. use Component.getMarkupId()
     CharSequence getJsForInterfaceUrl(CharSequence url)
              This generates a piece of javascript code that sets the url in the special hidden field and submits the form.
     Bytes getMaxSize()
              Gets the maximum size for uploads.
    protected  String getMethod()
              Gets the HTTP submit method that will appear in form markup.
     IModel<T> getModel()
              Gets model
     T getModelObject()
              Gets model object
     Form<?> getRootForm()
              Returns the root form or this, if this is the root form.
    static String getRootFormRelativeId(Component component)
              Utility method to assemble an id to distinct form components from diferent nesting levels.
    protected  boolean getStatelessHint()
              Returns whether the component can be stateless.
     String getValidatorKeyPrefix()
              Returns the prefix used when building validator keys.
    protected  IValuePersister getValuePersister()
              Gets the form component persistence manager; it is lazy loaded.
    protected  boolean handleMultiPart()
              Handles multi-part processing of the submitted data.
     boolean hasError()
              Gets whether the current form has any error registered.
    protected  void internalOnModelChanged()
              THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
     boolean isRootForm()
              Returns whether the form is a root form, which means that there's no other form in it's parent hierarchy.
     boolean isSubmitted()
              Checks if this form has been submitted during the current request
     boolean isVersioned()
              Method made final because we want to ensure users call setVersioned.
     void loadPersistentFormComponentValues()
              THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
    protected  void markFormComponentsInvalid()
              Mark each form component on this form invalid.
    protected  void markFormComponentsValid()
              Mark each form component on this form and on nested forms valid.
    protected  void onBeforeRender()
              Called just before a component is rendered.
    protected  void onComponentTag(ComponentTag tag)
              Processes the component tag.
    protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
              Append an additional hidden input tag to support anchor tags that can submit a form.
    protected  void onDetach()
              Called to allow a component to detach resources after use.
    protected  void onError()
              Method to override if you want to do something special when an error occurs (other than simply displaying validation errors).
    protected  void onFileUploadException(FileUploadException e, Map<String,Object> model)
              The default message may look like "..
     void onFormSubmitted()
              THIS METHOD IS NOT PART OF THE WICKET API.
    protected  void onSubmit()
              Implemented by subclasses to deal with form submits.
    protected  void onValidate()
              Callback during the validation stage of the form
    protected  void onValidateModelObjects()
              Called after form components have updated their models.
     boolean process()
              Deprecated. use process(IFormSubmittingComponent)
     void process(IFormSubmittingComponent submittingComponent)
              Process the form.
    protected  void registerJavascriptNamespaces(IHeaderResponse response)
              Produces javascript that registereds Wicket.Forms namespaces
     void remove(IFormValidator validator)
              Removes a form validator from the form.
     void removePersistentFormComponentValues(boolean disablePersistence)
              Removes already persisted data for all FormComponent children and disable persistence for the same components.
     void renderHead(IHeaderResponse response)
              Render to the web response whatever the component wants to contribute to the head section.
    protected  void renderPlaceholderTag(ComponentTag tag, Response response)
              Renders a placeholder tag for the component when it is invisible and Component.setOutputMarkupPlaceholderTag(boolean) has been called with true.
     void setDefaultButton(IFormSubmittingComponent submittingComponent)
              Sets the default IFormSubmittingComponent.
     void setMaxSize(Bytes maxSize)
              Sets the maximum size for uploads.
     void setModel(IModel<T> model)
              Sets model
     void setModelObject(T object)
              Sets model object
     void setMultiPart(boolean multiPart)
              Set to true to use enctype='multipart/form-data', and to process file uploads by default multiPart = false
     Component setVersioned(boolean isVersioned)
               
    protected  void updateFormComponentModels()
              Update the model of all components on this form and nested forms using the fields that were sent with the current request.
    protected  void validate()
              Validates the form by checking required fields, converting raw input and running validators for every form component, and last running global form validators.
    protected  void validateComponents()
              Triggers type conversion on form components
    protected  void validateFormValidator(IFormValidator validator)
              Validates form with the given form validator
    protected  void validateFormValidators()
              Triggers any added IFormValidators.
     void visitFormComponents(FormComponent.IVisitor visitor)
              Convenient and typesafe way to visit all the form components on a form.
     void visitFormComponentsPostOrder(FormComponent.IVisitor visitor)
              Convenient and typesafe way to visit all the form components on a form postorder (deepest first)
    protected  void writeParamsAsHiddenFields(String[] params, AppendingStringBuffer buffer)
               
     
    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, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren
     
    Methods inherited from class org.apache.wicket.Component
    add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeginRequest, onConfigure, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVisibilityAllowed, 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
     

    Field Detail

    METHOD_GET

    public static final String METHOD_GET
    Constant for specifying how a form is submitted, in this case using get.

    See Also:
    Constant Field Values

    METHOD_POST

    public static final String METHOD_POST
    Constant for specifying how a form is submitted, in this case using post.

    See Also:
    Constant Field Values
    Constructor Detail

    Form

    public Form(String id)
    Constructs a form with no validation.

    Parameters:
    id - See Component

    Form

    public Form(String id,
                IModel<T> model)
    Parameters:
    id - See Component
    model - See Component
    See Also:
    Component.Component(String, IModel)
    Method Detail

    add

    public void add(IFormValidator validator)
    Adds a form validator to the form.

    Parameters:
    validator - validator
    Throws:
    IllegalArgumentException - if validator is null
    See Also:
    IFormValidator, IValidatorAddListener

    remove

    public void remove(IFormValidator validator)
    Removes a form validator from the form.

    Parameters:
    validator - validator
    Throws:
    IllegalArgumentException - if validator is null
    See Also:
    IFormValidator

    clearInput

    public final void clearInput()
    Clears the input from the form's nested children of type FormComponent. This method is typically called when a form needs to be reset.


    error

    public final void error(String error,
                            Map<String,Object> args)
    Registers an error feedback message for this component

    Parameters:
    error - error message
    args - argument replacement map for ${key} variables

    findSubmittingButton

    public final IFormSubmittingComponent findSubmittingButton()
    Gets the IFormSubmittingComponent which submitted this form.

    Returns:
    The component which submitted this form, or null if the processing was not triggered by a registered IFormSubmittingComponent

    getDefaultButton

    public final IFormSubmittingComponent getDefaultButton()
    Gets the default IFormSubmittingComponent. If set (not null), a hidden submit component will be rendered right after the form tag, so that when users press enter in a textfield, this submit component's action will be selected. If no default component is set (it is null), nothing additional is rendered.

    WARNING: note that this is a best effort only. Unfortunately having a 'default' button in a form is ill defined in the standards, and of course IE has it's own way of doing things.

    There can be only one default submit component per form hierarchy. So if you want to get the default component on a nested form, it will actually delegate the call to root form.

    Returns:
    The submit component to set as the default IFormSubmittingComponent, or null when you want to 'unset' any previously set default IFormSubmittingComponent

    getFormValidators

    public final Collection<IFormValidator> getFormValidators()
    Gets all IFormValidators added to this form

    Returns:
    unmodifiable collection of IFormValidators

    getJsForInterfaceUrl

    public final CharSequence getJsForInterfaceUrl(CharSequence url)
    This generates a piece of javascript code that sets the url in the special hidden field and submits the form. Warning: This code should only be called in the rendering phase for form components inside the form because it uses the css/javascript id of the form which can be stored in the markup.

    Parameters:
    url - The interface url that has to be stored in the hidden field and submitted
    Returns:
    The javascript code that submits the form.

    getMaxSize

    public Bytes getMaxSize()
    Gets the maximum size for uploads. If null, the setting IApplicationSettings.getDefaultMaximumUploadSize() is used.

    Returns:
    the maximum size

    getRootForm

    public Form<?> getRootForm()
    Returns the root form or this, if this is the root form.

    Returns:
    root form or this form

    getValidatorKeyPrefix

    public String getValidatorKeyPrefix()
    Returns the prefix used when building validator keys. This allows a form to use a separate "set" of keys. For example if prefix "short" is returned, validator key short.Required will be tried instead of Required key.

    This can be useful when different designs are used for a form. In a form where error messages are displayed next to their respective form components as opposed to at the top of the form, the ${label} attribute is of little use and only causes redundant information to appear in the message. Forms like these can return the "short" (or any other string) validator prefix and declare key: short.Required=required to override the longer message which is usually declared like this: Required=${label} is a required field

    Returned prefix will be used for all form components. The prefix can also be overridden on form component level by overriding FormComponent.getValidatorKeyPrefix()

    Returns:
    prefix prepended to validator keys

    hasError

    public final boolean hasError()
    Gets whether the current form has any error registered.

    Returns:
    True if this form has at least one error.

    isRootForm

    public boolean isRootForm()
    Returns whether the form is a root form, which means that there's no other form in it's parent hierarchy.

    Returns:
    true if form is a root form, false otherwise

    isSubmitted

    public final boolean isSubmitted()
    Checks if this form has been submitted during the current request

    Returns:
    true if the form has been submitted during this request, false otherwise

    isVersioned

    public boolean isVersioned()
    Method made final because we want to ensure users call setVersioned.

    Overrides:
    isVersioned in class Component
    Returns:
    True if this component is versioned
    See Also:
    Component.isVersioned()

    loadPersistentFormComponentValues

    public final void loadPersistentFormComponentValues()
    THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

    Retrieves FormComponent values related to the page using the persister and assign the values to the FormComponent. Thus initializing them.


    onFormSubmitted

    public final void onFormSubmitted()
    THIS METHOD IS NOT PART OF THE WICKET API. DO NOT ATTEMPT TO OVERRIDE OR CALL IT. Handles form submissions.

    Specified by:
    onFormSubmitted in interface IFormSubmitListener
    See Also:
    validate()

    process

    public void process(IFormSubmittingComponent submittingComponent)
    Process the form. Though you can override this method to provide your own algorithm, it is not recommended to do so.

    See the class documentation for further details on the form processing

    Parameters:
    submittingComponent - component responsible for submitting the form, or null if none (eg the form has been submitted via the enter key or javascript calling form.onsubmit())
    See Also:
    for an easy way to process submitting component in the default manner

    onValidateModelObjects

    protected void onValidateModelObjects()
    Called after form components have updated their models. This is a late-stage validation that allows outside frameworks to validate any beans that the form is updating. This validation method is not preferred because at this point any errors will not unroll any changes to the model object, so the model object is in a modified state potentially containing illegal values. However, with external frameworks there may not be an alternate way to validate the model object. A good example of this is a JSR303 Bean Validator validating the model object to check any class-level constraints, in order to check such constaints the model object must contain the values set by the user.


    process

    @Deprecated
    public boolean process()
    Deprecated. use process(IFormSubmittingComponent)

    Process the form. Though you can override this method to provide your whole own algorithm, it is not recommended to do so.

    See the class documentation for further details on the form processing

    Returns:
    False if the form had an error

    callOnError

    protected void callOnError()
    Calls onError on this Form and any enabled and visible nested form, if the respective Form actually has errors.


    removePersistentFormComponentValues

    public void removePersistentFormComponentValues(boolean disablePersistence)
    Removes already persisted data for all FormComponent children and disable persistence for the same components.

    Parameters:
    disablePersistence - if true, disable persistence for all FormComponents on that page. If false, it will remain unchanged.
    See Also:
    Page.removePersistedFormData(Class, boolean)

    setDefaultButton

    public final void setDefaultButton(IFormSubmittingComponent submittingComponent)
    Sets the default IFormSubmittingComponent. If set (not null), a hidden submit component will be rendered right after the form tag, so that when users press enter in a textfield, this submit component's action will be selected. If no default component is set (so unset by calling this method with null), nothing additional is rendered.

    WARNING: note that this is a best effort only. Unfortunately having a 'default' button in a form is ill defined in the standards, and of course IE has it's own way of doing things.

    There can be only one default button per form hierarchy. So if you set default button on a nested form, it will actually delegate the call to root form.

    Parameters:
    submittingComponent - The component to set as the default submitting component, or null when you want to 'unset' any previously set default component

    setMaxSize

    public void setMaxSize(Bytes maxSize)
    Sets the maximum size for uploads. If null, the setting IApplicationSettings.getDefaultMaximumUploadSize() is used.

    Parameters:
    maxSize - The maximum size

    setMultiPart

    public void setMultiPart(boolean multiPart)
    Set to true to use enctype='multipart/form-data', and to process file uploads by default multiPart = false

    Parameters:
    multiPart - whether this form should behave as a multipart form

    setVersioned

    public final Component setVersioned(boolean isVersioned)
    Overrides:
    setVersioned in class Component
    Parameters:
    isVersioned - True to turn on versioning for this component, false to turn it off for this component and any children.
    Returns:
    This
    See Also:
    Component.setVersioned(boolean)

    visitFormComponents

    public final void visitFormComponents(FormComponent.IVisitor visitor)
    Convenient and typesafe way to visit all the form components on a form.

    Parameters:
    visitor - The visitor interface to call

    visitFormComponentsPostOrder

    public final void visitFormComponentsPostOrder(FormComponent.IVisitor visitor)
    Convenient and typesafe way to visit all the form components on a form postorder (deepest first)

    Parameters:
    visitor - The visitor interface to call

    appendDefaultButtonField

    protected void appendDefaultButtonField(MarkupStream markupStream,
                                            ComponentTag openTag)
    If a default IFormSubmittingComponent was set on this form, this method will be called to render an extra field with an invisible style so that pressing enter in one of the textfields will do a form submit using this component. This method is overridable as what we do is best effort only, and may not what you want in specific situations. So if you have specific usability concerns, or want to follow another strategy, you may override this method.

    Parameters:
    markupStream - The markup stream
    openTag - The open tag for the body

    beforeUpdateFormComponentModels

    protected void beforeUpdateFormComponentModels()
    Template method to allow clients to do any processing (like recording the current model so that, in case onSubmit does further validation, the model can be rolled back) before the actual updating of form component models is done.


    delegateSubmit

    protected void delegateSubmit(IFormSubmittingComponent submittingComponent)
    Called (by the default implementation of 'process') when all fields validated, the form was updated and it's data was allowed to be persisted. It is meant for delegating further processing to clients.

    This implementation first finds out whether the form processing was triggered by a nested IFormSubmittingComponent of this form. If that is the case, that component's onSubmit is called first.

    Regardless of whether a submitting component was found, the form's onSubmit method is called next.

    Parameters:
    submittingComponent - the component that triggered this form processing, or null if the processing was triggered by something else (like a non-Wicket submit button or a javascript execution)

    getHiddenFieldId

    public final String getHiddenFieldId()
    Returns the HiddenFieldId which will be used as the name and id property of the hiddenfield that is generated for event dispatches.

    Returns:
    The name and id of the hidden field.

    getJavascriptId

    @Deprecated
    protected final String getJavascriptId()
    Deprecated. use Component.getMarkupId()

    Returns the javascript/css id of this form that will be used to generated the id="xxx" attribute.

    Returns:
    The javascript/css id of this form.

    getMethod

    protected String getMethod()
    Gets the HTTP submit method that will appear in form markup. If no method is specified in the template, "post" is the default. Note that the markup-declared HTTP method may not correspond to the one actually used to submit the form; in an Ajax submit, for example, JavaScript event handlers may submit the form with a "get" even when the form method is declared as "post." Therefore this method should not be considered a guarantee of the HTTP method used, but a value for the markup only. Override if you have a requirement to alter this behavior.

    Returns:
    the submit method specified in markup.

    getStatelessHint

    protected boolean getStatelessHint()
    Description copied from class: Component
    Returns whether the component can be stateless. Also the component behaviors must be stateless, otherwise the component will be treat as stateful. In order for page to be stateless (and not to be stored in session), all components (and component behaviors) must be stateless.

    Overrides:
    getStatelessHint in class Component
    Returns:
    whether the component can be stateless
    See Also:
    Component.getStatelessHint()

    getValuePersister

    protected IValuePersister getValuePersister()
    Gets the form component persistence manager; it is lazy loaded.

    Returns:
    The form component value persister

    handleMultiPart

    protected boolean handleMultiPart()
    Handles multi-part processing of the submitted data. WARNING If this method is overridden it can break FileUploadFields on this form

    Returns:
    false if form is multipart and upload failed

    onFileUploadException

    protected void onFileUploadException(FileUploadException e,
                                         Map<String,Object> model)
    The default message may look like ".. may not exceed 10240 Bytes..". Which is ok, but sometimes you may want something like "10KB". By subclassing this method you may replace maxSize in the model or add you own property and use that in your error message.

    Don't forget to call super.onFileUploadException(e, model) at the end of your method.

    Parameters:
    e -
    model -

    internalOnModelChanged

    protected void internalOnModelChanged()
    Description copied from class: Component
    THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.

    Called anytime a model is changed via setModel or setModelObject.

    Overrides:
    internalOnModelChanged in class Component
    See Also:
    Component.internalOnModelChanged()

    markFormComponentsInvalid

    protected final void markFormComponentsInvalid()
    Mark each form component on this form invalid.


    markFormComponentsValid

    protected final void markFormComponentsValid()
    Mark each form component on this form and on nested forms valid.


    onComponentTag

    protected void onComponentTag(ComponentTag tag)
    Description copied from class: Component
    Processes the component tag.

    Overrides of this method most likely should call the super implementation.

    Overrides:
    onComponentTag in class Component
    Parameters:
    tag - Tag to modify
    See Also:
    Component.onComponentTag(ComponentTag)

    renderPlaceholderTag

    protected void renderPlaceholderTag(ComponentTag tag,
                                        Response response)
    Description copied from class: Component
    Renders a placeholder tag for the component when it is invisible and Component.setOutputMarkupPlaceholderTag(boolean) has been called with true.

    Overrides:
    renderPlaceholderTag in class Component
    Parameters:
    tag - component tag
    response - response

    encodeUrlInHiddenFields

    protected boolean encodeUrlInHiddenFields()
    Returns:
    true if form's method is 'get'

    onComponentTagBody

    protected void onComponentTagBody(MarkupStream markupStream,
                                      ComponentTag openTag)
    Append an additional hidden input tag to support anchor tags that can submit a form.

    Overrides:
    onComponentTagBody in class MarkupContainer
    Parameters:
    markupStream - The markup stream
    openTag - The open tag for the body

    writeParamsAsHiddenFields

    protected void writeParamsAsHiddenFields(String[] params,
                                             AppendingStringBuffer buffer)
    Parameters:
    params -
    buffer -

    onDetach

    protected void onDetach()
    Description copied from class: Component
    Called to allow a component to detach resources after use. Overrides of this method MUST call the super implementation, the most logical place to do this is the last line of the override method.

    Overrides:
    onDetach in class Component
    See Also:
    Component.onDetach()

    onError

    protected void onError()
    Method to override if you want to do something special when an error occurs (other than simply displaying validation errors).


    onBeforeRender

    protected void onBeforeRender()
    Description copied from class: Component
    Called just before a component is rendered.

    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.

    Overrides:
    onBeforeRender in class Component
    See Also:
    Component.callOnBeforeRenderIfNotVisible()

    onSubmit

    protected void onSubmit()
    Implemented by subclasses to deal with form submits.


    updateFormComponentModels

    protected final void updateFormComponentModels()
    Update the model of all components on this form and nested forms using the fields that were sent with the current request. This method only updates models when the Form.validate() is called first that takes care of the conversion for the FormComponents. Normally this method will not be called when a validation error occurs in one of the form components.

    See Also:
    FormComponent.updateModel()

    validate

    protected final void validate()
    Validates the form by checking required fields, converting raw input and running validators for every form component, and last running global form validators. This method is typically called before updating any models.

    NOTE: in most cases, custom validations on the form can be achieved using an IFormValidator that can be added using addValidator().


    onValidate

    protected void onValidate()
    Callback during the validation stage of the form


    validateComponents

    protected final void validateComponents()
    Triggers type conversion on form components


    validateFormValidator

    protected final void validateFormValidator(IFormValidator validator)
    Validates form with the given form validator

    Parameters:
    validator -

    validateFormValidators

    protected final void validateFormValidators()
    Triggers any added IFormValidators.


    getInputNamePrefix

    protected String getInputNamePrefix()
    Allows to customize input names of form components inside this form.

    Returns:
    String that well be used as prefix to form component input names

    getModel

    public final IModel<T> getModel()
    Gets model

    Returns:
    model

    setModel

    public final void setModel(IModel<T> model)
    Sets model

    Parameters:
    model -

    getModelObject

    public final T getModelObject()
    Gets model object

    Returns:
    model object

    setModelObject

    public final void setModelObject(T object)
    Sets model object

    Parameters:
    object -

    findForm

    public static Form<?> findForm(Component component)
    Parameters:
    component -
    Returns:
    The parent form for component

    renderHead

    public void renderHead(IHeaderResponse response)
    Render to the web response whatever the component wants to contribute to the head section. TODO: Post 1.3, add component parameter, so that the behaviors dont' have to track component instances

    Specified by:
    renderHead in interface IHeaderContributor
    Parameters:
    response - Response object

    registerJavascriptNamespaces

    protected void registerJavascriptNamespaces(IHeaderResponse response)
    Produces javascript that registereds Wicket.Forms namespaces

    Parameters:
    response -

    getRootFormRelativeId

    public static String getRootFormRelativeId(Component component)
    Utility method to assemble an id to distinct form components from diferent nesting levels. Useful to generate input names attributes.

    Parameters:
    component -
    Returns:
    form relative identification string


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