T - type of model objectpublic abstract class Link<T> extends AbstractLink implements ILinkListener, IGenericComponent<T>
You can use a link like:
add(new Link("myLink")
{
public void onClick()
{
// do something here...
}
);
and in your HTML file:
<a href="#" wicket:id="myLink">click here</a>or:
<td wicket:id="myLink">my clickable column</td>The following snippet shows how to pass a parameter from the Page creating the Page to the Page responded by the Link.
add(new Link<MyObject>("link", listItem.getModel())
{
public void onClick()
{
MyObject obj = getModelObject();
setResponsePage(new MyPage(obj));
}
ENABLE, 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_DEQUEINGINTERFACE| Constructor and Description |
|---|
Link(String id) |
Link(String id,
IModel<T> model) |
| Modifier and Type | Method and Description |
|---|---|
protected CharSequence |
appendAnchor(ComponentTag tag,
CharSequence url)
Appends any anchor to the url if the url is not null and the url does not already contain an
anchor (url.indexOf('#') != -1).
|
Component |
getAnchor()
Gets any anchor component.
|
boolean |
getAutoEnable()
Gets whether link should automatically enable/disable based on current page.
|
IModel<T> |
getModel()
Typesafe getter for the model
|
T |
getModelObject()
Typesafe getter for the model's object
|
protected CharSequence |
getOnClickScript(CharSequence url) |
PopupSettings |
getPopupSettings()
Gets the popup specification.
|
protected boolean |
getStatelessHint()
Returns whether the component can be stateless.
|
protected CharSequence |
getURL()
Gets the url to use for this link.
|
boolean |
isEnabled()
Gets whether this component is enabled.
|
protected boolean |
linksTo(Page page)
Whether this link refers to the given page.
|
abstract void |
onClick()
Called when a link is clicked.
|
protected void |
onComponentTag(ComponentTag tag)
Handles this link's tag.
|
void |
onLinkClicked()
THIS METHOD IS NOT PART OF THE WICKET API.
|
Link<T> |
setAnchor(Component anchor)
Sets an anchor component.
|
Link<T> |
setAutoEnable(boolean autoEnable)
Sets whether this link should automatically enable/disable based on current page.
|
void |
setModel(IModel<T> model)
Typesafe setter for the model
|
void |
setModelObject(T object)
Typesafe setter for the model object
|
Link<T> |
setPopupSettings(PopupSettings popupSettings)
Sets the popup specification.
|
disableLink, getBody, onComponentTagBody, onDetach, setBodygetWebApplication, 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, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, 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, wrappublic Link(String id)
Component.Component(String)public Link(String id, IModel<T> model)
id - model - Component.Component(String, IModel)public Component getAnchor()
public final boolean getAutoEnable()
public final PopupSettings getPopupSettings()
public boolean isEnabled()
ComponentisEnabled in class ComponentComponent.isEnabled()protected boolean getStatelessHint()
ComponentgetStatelessHint in class ComponentComponent.getStatelessHint()public abstract void onClick()
public final void onLinkClicked()
onLinkClicked in interface ILinkListenerILinkListenerpublic Link<T> setAnchor(Component anchor)
Component.getOutputMarkupId() flag true, or it must be attached to a <a tag with a
href attribute of more than one character starting with '#' ('<a href="#someAnchor" ...
').anchor - The anchorpublic final Link<T> setAutoEnable(boolean autoEnable)
autoEnable - whether this link should automatically enable/disable based on current page.public final Link<T> setPopupSettings(PopupSettings popupSettings)
popupSettings - the popup specification.protected CharSequence appendAnchor(ComponentTag tag, CharSequence url)
Component.getMarkupId() if Component.getOutputMarkupId()
returns true, or if the anchor component does not output it's id, this method will try to
retrieve the id from the markup directly. If neither is found, an
exception is thrown. If no anchor component was set, but the
link component is attached to a <a element, this method will append what is in the href
attribute if there is one, starts with a '#' and has more than one character.
You can override this method, but it means that you have to take care of whatever is done with any set anchor component yourself. You also have to manually append the '#' at the right place.
tag - The component tagurl - The url to start withprotected CharSequence getOnClickScript(CharSequence url)
url - The url for the linkprotected CharSequence getURL()
protected boolean linksTo(Page page)
page - A pageprotected void onComponentTag(ComponentTag tag)
onComponentTag in class Componenttag - the component tagComponent.onComponentTag(ComponentTag)public final IModel<T> getModel()
IGenericComponentgetModel in interface IGenericComponent<T>public final void setModel(IModel<T> model)
IGenericComponentsetModel in interface IGenericComponent<T>model - the new modelpublic final T getModelObject()
IGenericComponentgetModelObject in interface IGenericComponent<T>public final void setModelObject(T object)
IGenericComponentsetModelObject in interface IGenericComponent<T>object - the new model objectCopyright © 2006–2021 Apache Software Foundation. All rights reserved.