|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.Component org.apache.wicket.MarkupContainer org.apache.wicket.markup.html.WebMarkupContainer org.apache.wicket.markup.html.link.AbstractLink org.apache.wicket.markup.html.form.AbstractSubmitLink org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink
public abstract class AjaxSubmitLink
A link that submits a form via ajax. Since this link takes the form as a constructor argument it does not need to be inside form's component hierarchy.
It works by splitting the javascript/Ajax calls from the normal non-ajax requests by generating:<a href="normal action url" onclick="ajax javascript script; return false;">link</a>If/when javascript is turned off in the browser, or it doesn't support javascript, then the browser will not respond to the onclick event, using the href directly. Wicket will then use a normal request target, and call the serverside onClick with a null
AjaxRequestTarget
.
If javascript is enabled, Wicket will send an ajax request, and process it serverside with an
AjaxRequestTarget
that is supplied to the server-side onClick method. The "return false"
in the <a href> onclick handler ensures the browser doesn't perform the normal request too.
The latter is nicely illustrated with this:
<a href="javascript:alert('href event handler');" onclick="alert('onclick event handler');">clicking me gives two alerts</a> <a href="javascript:alert('href event handler');" onclick="alert('onclick event handler');return false;">clicking me gives only one alert</a>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor, Component.VisibilityChange |
Field Summary |
---|
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
AjaxSubmitLink(java.lang.String id)
Construct. |
|
AjaxSubmitLink(java.lang.String id,
Form form)
Construct. |
Method Summary | |
---|---|
protected IAjaxCallDecorator |
getAjaxCallDecorator()
Returns the IAjaxCallDecorator that will be used to modify the generated javascript. |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
protected void |
onError(AjaxRequestTarget target,
Form form)
Listener method invoked on form submit with errors |
void |
onSubmit()
Final implementation of the Button's onSubmit. |
protected abstract void |
onSubmit(AjaxRequestTarget target,
Form form)
Listener method invoked on form submit |
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 |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AjaxSubmitLink(java.lang.String id)
id
- public AjaxSubmitLink(java.lang.String id, Form form)
id
- form
- Method Detail |
---|
protected IAjaxCallDecorator getAjaxCallDecorator()
IAjaxCallDecorator
that will be used to modify the generated javascript.
This is the preferred way of changing the javascript in the onclick handler
protected void onComponentTag(ComponentTag tag)
Component
onComponentTag
in class Component
tag
- Tag to modifypublic final void onSubmit()
Button.onSubmit()
protected abstract void onSubmit(AjaxRequestTarget target, Form form)
target
- form
- protected void onError(AjaxRequestTarget target, Form form)
target
- form
- TODO 1.3: Make abstract to be consistent with onsubmit()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |