org.apache.wicket.markup.html.form
Class SubmitLink

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.link.AbstractLink
                  extended by org.apache.wicket.markup.html.form.AbstractSubmitLink
                      extended by org.apache.wicket.markup.html.form.SubmitLink
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator, IFormSubmittingComponent

public class SubmitLink
extends AbstractSubmitLink

A link which can be used exactly like a Button to submit a Form. The onclick 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 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 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, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
SubmitLink(String id)
          With this constructor the SubmitLink must be inside a Form.
SubmitLink(String id, Form<?> form)
          With this constructor the SubmitLink will submit the Form that is given when the link is clicked on.
SubmitLink(String id, IModel<?> model)
          With this constructor the SubmitLink must be inside a Form.
SubmitLink(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
protected  String getTriggerJavaScript()
          The javascript which triggers this link.
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.
 void onSubmit()
          Override this method to provide special submit handling in a multi-button form.
protected  boolean shouldInvokeJavascriptFormOnsubmit()
          Controls whether or not clicking on this link will invoke form's javascript onsubmit handler.
 
Methods inherited from class org.apache.wicket.markup.html.form.AbstractSubmitLink
getDefaultFormProcessing, getForm, getInputName, setDefaultFormProcessing
 
Methods inherited from class org.apache.wicket.markup.html.link.AbstractLink
disableLink, getAfterDisabledLink, getBeforeDisabledLink, isLinkEnabled, onBeforeRender, onComponentTagBody, setAfterDisabledLink, setBeforeDisabledLink
 
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, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeginRequest, onConfigure, onDetach, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, 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
 

Constructor Detail

SubmitLink

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

Parameters:
id - The id of the submitlink.

SubmitLink

public SubmitLink(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(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(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

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.

See Also:
ILinkListener.onLinkClicked()

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(org.apache.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

getTriggerJavaScript

protected final String getTriggerJavaScript()
The javascript which triggers this link.

Returns:
The javascript

onSubmit

public void onSubmit()
Description copied from interface: IFormSubmittingComponent
Override this method to provide special submit handling in a multi-button form. It is called whenever the user clicks this particular button.

See Also:
IFormSubmittingComponent.onSubmit()


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