wicket.markup.html.form
Class SubmitLink

java.lang.Object
  extended by wicket.Component
      extended by wicket.MarkupContainer
          extended by wicket.markup.html.WebMarkupContainer
              extended by wicket.markup.html.form.FormComponent
                  extended by wicket.markup.html.form.Button
                      extended by wicket.markup.html.form.SubmitLink
All Implemented Interfaces:
java.io.Serializable, IRequestListener, ILinkListener

public class SubmitLink
extends Button
implements ILinkListener

A link which can be used exactly like a Button to submit a Form. The href of the link will use JavaScript to submit the form.

You can use this class 2 ways. First with the constructor without a Form object then this Link must be inside a Form so that it knows what form to submit to. Second way is to use the Form constructor then that form will be used to submit to.

     Form f = new Form("linkForm", new CompoundPropertyModel(mod));
     f.add(new TextField("value1"));
     f.add(new SubmitLink("link1") {
         protected void onSubmit() {
             System.out.println("Link1 was clicked, value1 is: "
                                 + mod.getValue1());
         };
      });
      add(new SubmitLink("link2",f) {
          protected void onSubmit() {
              System.out.println("Link2 was clicked, value1 is: "
                                 + mod.getValue1());
           };
      });
          
      <form wicket:id="linkForm" >
          <input wicket:id="value1" type="text" size="30"/>
          <a wicket:id="link1">Press link1 to submit</a>
          <input type="submit" value="Send"/>
      </form>
      <a wicket:id="link2">Press link 2 to submit</a>
 

If this link is not placed in a form or given a form to cooperate with, it will fall back to a normal link behavior, meaning that Button.onSubmit() will be called without any other consequences.

Author:
chris, jcompagner, Igor Vaynberg (ivaynberg), Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class wicket.markup.html.form.FormComponent
FormComponent.IVisitor
 
Nested classes/interfaces inherited from class wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
 
Fields inherited from class wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Fields inherited from interface wicket.markup.html.link.ILinkListener
INTERFACE
 
Constructor Summary
SubmitLink(java.lang.String id)
          With this constructor the SubmitLink must be inside a Form.
SubmitLink(java.lang.String id, Form form)
          With this constructor the SubmitLink will submit the Form that is given when the link is clicked on.
SubmitLink(java.lang.String id, IModel model)
          With this constructor the SubmitLink must be inside a Form.
SubmitLink(java.lang.String id, IModel model, Form form)
          With this constructor the SubmitLink will submit the Form that is given when the link is clicked on.
 
Method Summary
 Form getForm()
           
protected  void onComponentTag(ComponentTag tag)
          Processes the component tag.
 void onLinkClicked()
          This method is here as a means to fall back on normal link behavior when this link is not nested in a form.
protected  boolean shouldInvokeJavascriptFormOnsubmit()
          Controls whether or not clicking on this link will invoke form's javascript onsubmit handler.
 
Methods inherited from class wicket.markup.html.form.Button
getDefaultFormProcessing, getOnClickScript, initModel, onSubmit, setDefaultFormProcessing, updateModel
 
Methods inherited from class wicket.markup.html.form.FormComponent
add, checkRequired, clearInput, convert, convertValue, error, getConvertedInput, getInput, getInputAsArray, getInputName, getLabel, getModelValue, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputAsStringArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isPersistent, isRequired, isValid, isValidated, onDetach, onDisabled, onInvalid, onValid, processInput, setLabel, setModelValue, setModelValue, setPersistent, setRequired, setType, supportsPersistence, valid, validate, validateRequired, validateValidators
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, internalAdd, internalAttach, internalDetach, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, continueToOriginalDestination, debug, detachBehaviors, detachModel, detachModels, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getOutputMarkupId, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasErrorMessage, hasFeedbackMessage, info, internalOnAttach, internalOnDetach, isActionAuthorized, isAncestorOf, isBehaviorAccepted, isEnableAllowed, isEnabled, isHeadRendered, isIgnoreAttributeModifier, isRenderAllowed, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onEndRequest, onModelChanged, onModelChanging, onRender, redirectToInterceptPage, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderedBehaviors, renderHead, replaceComponentTagBody, replaceWith, resetHeadRendered, sameRootModel, sameRootModel, setAuto, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMetaData, setModelObject, setOutputMarkupId, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubmitLink

public SubmitLink(java.lang.String id)
With this constructor the SubmitLink must be inside a Form.

Parameters:
id - The id of the submitlink.

SubmitLink

public SubmitLink(java.lang.String id,
                  Form form)
With this constructor the SubmitLink will submit the Form that is given when the link is clicked on. The SubmitLink doesn't have to be in inside the Form. But currently if it is outside the Form and the SubmitLink will be rendered first. Then the Form will have a generated javascript/css id. The markup javascript/css id that can exist will be overridden.

Parameters:
id - The id of the submitlink.
form - The form which this submitlink must submit.

SubmitLink

public SubmitLink(java.lang.String id,
                  IModel model)
With this constructor the SubmitLink must be inside a Form.

Parameters:
id - The id of the submitlink.
model - The model for this submitlink, It won't be used by the submit link itself, but it can be used for keeping state

SubmitLink

public SubmitLink(java.lang.String id,
                  IModel model,
                  Form form)
With this constructor the SubmitLink will submit the Form that is given when the link is clicked on. The SubmitLink doesn't have to be in inside the Form. But currently if it is outside the Form and the SubmitLink will be rendered first. Then the Form will have a generated javascript/css id. The markup javascript/css id that can exist will be overridden.

Parameters:
id - The id of the submitlink.
model - The model for this submitlink, It won't be used by the submit link itself, but it can be used for keeping state
form - The form which this submitlink must submit.
Method Detail

getForm

public final Form getForm()
Overrides:
getForm in class FormComponent
Returns:
the Form for which this submit link submits. Null if there is no form.

onLinkClicked

public final void onLinkClicked()
This method is here as a means to fall back on normal link behavior when this link is not nested in a form. Not intended to be called by clients directly.

Specified by:
onLinkClicked in interface ILinkListener
See Also:
ILinkListener.onLinkClicked()

onComponentTag

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

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

shouldInvokeJavascriptFormOnsubmit

protected boolean shouldInvokeJavascriptFormOnsubmit()
Controls whether or not clicking on this link will invoke form's javascript onsubmit handler. True by default.

Returns:
true if form's javascript onsubmit handler should be invoked, false otherwise


Copyright © 2004-2007 Wicket developers. All Rights Reserved.