|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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.link.Link
public abstract class Link
Implementation of a hyperlink component. A link can be used with an anchor (<a href...) element or any element that supports the onclick javascript event handler (such as buttons, td elements, etc). When used with an anchor, a href attribute will be generated. When used with any other element, an onclick javascript event handler attribute will be generated.
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("link", listItem.getModel()) { public void onClick() { MyObject obj = (MyObject)getModelObject(); setResponsePage(new MyPage(obj)); }
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 |
Fields inherited from interface org.apache.wicket.markup.html.link.ILinkListener |
---|
INTERFACE |
Constructor Summary | |
---|---|
Link(java.lang.String id)
|
|
Link(java.lang.String id,
IModel object)
|
Method Summary | |
---|---|
protected java.lang.CharSequence |
appendAnchor(ComponentTag tag,
java.lang.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. |
protected java.lang.CharSequence |
getOnClickScript(java.lang.CharSequence url)
|
protected java.lang.String |
getOnClickScript(java.lang.String url)
Deprecated. this method will be removed by getOnClickScript(CharSequence) shortly.
Please override that method instead. |
PopupSettings |
getPopupSettings()
Gets the popup specification. |
protected boolean |
getStatelessHint()
Returns whether the component can be stateless. |
protected java.lang.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 |
setAnchor(Component anchor)
Sets an anchor component. |
Link |
setAutoEnable(boolean autoEnable)
Sets whether this link should automatically enable/disable based on current page. |
Link |
setPopupSettings(PopupSettings popupSettings)
Sets the popup specification. |
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 Link(java.lang.String id)
Component.Component(String)
public Link(java.lang.String id, IModel object)
Component.Component(String, IModel)
Method Detail |
---|
public Component getAnchor()
public final boolean getAutoEnable()
public PopupSettings getPopupSettings()
public boolean isEnabled()
Component
isEnabled
in class Component
Component.isEnabled()
protected boolean getStatelessHint()
Component
getStatelessHint
in class Component
public abstract void onClick()
public final void onLinkClicked()
onLinkClicked
in interface ILinkListener
ILinkListener
public Link 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 anchor
public final Link setAutoEnable(boolean autoEnable)
autoEnable
- whether this link should automatically enable/disable based on current page.
public final Link setPopupSettings(PopupSettings popupSettings)
popupSettings
- the popup specification.
protected java.lang.CharSequence appendAnchor(ComponentTag tag, java.lang.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 with
protected java.lang.CharSequence getOnClickScript(java.lang.CharSequence url)
url
- The url for the link
protected java.lang.String getOnClickScript(java.lang.String url)
getOnClickScript(CharSequence)
shortly.
Please override that method instead.
url
- The url for the link
protected java.lang.CharSequence getURL()
protected boolean linksTo(Page page)
page
- A page
protected void onComponentTag(ComponentTag tag)
onComponentTag
in class Component
tag
- the component tagComponent.onComponentTag(ComponentTag)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |