wicket.markup.html.link
Class Link

java.lang.Object
  extended bywicket.Component
      extended bywicket.MarkupContainer
          extended bywicket.markup.html.WebMarkupContainer
              extended bywicket.markup.html.link.Link
All Implemented Interfaces:
ILinkListener, IRequestListener, java.io.Serializable
Direct Known Subclasses:
BookmarkablePageLink, PageLink, PopupCloseLink, ResourceLink

public abstract class Link
extends WebMarkupContainer
implements ILinkListener

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(RequestCycle cycle)
         {
            // 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>
 

Author:
Jonathan Locke, Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class wicket.Component
Component.ComponentModelChange, Component.IVisitor, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class wicket.Component
FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4
 
Constructor Summary
Link(java.lang.String id)
           
Link(java.lang.String id, IModel object)
           
 
Method Summary
 java.lang.String getAfterDisabledLink()
          Gets the insertion string to allow disabled links to look like Disabled link .
 boolean getAutoEnable()
          Gets whether link should automatically enable/disable based on current page.
 java.lang.String getBeforeDisabledLink()
          Gets the insertion string to allow disabled links to look like Disabled link .
protected  java.lang.String getOnClickScript(java.lang.String url)
           
 PopupSettings getPopupSettings()
          Gets the popup specification.
protected  java.lang.String getURL()
          Gets the url to use for this link.
protected  void internalOnBeginRequest()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 boolean isEnabled()
          Gets whether this link 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.
protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
          Renders this link's body.
 void onLinkClicked()
          THIS METHOD IS NOT PART OF THE WICKET API.
 void setAfterDisabledLink(java.lang.String afterDisabledLink)
          Sets the insertion string to allow disabled links to look like Disabled link .
 Link setAutoEnable(boolean autoEnable)
          Sets whether this link should automatically enable/disable based on current page.
 void setBeforeDisabledLink(java.lang.String beforeDisabledLink)
          Sets the insertion string to allow disabled links to look like Disabled link .
 Link setEnabled(boolean enabled)
          Sets link enabled state.
 Link setPopupSettings(PopupSettings popupSettings)
          Sets the popup specification.
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, onRender
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getMarkupStream, internalAdd, internalBeginRequest, internalEndRequest, iterator, remove, removeAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, debug, detachModel, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getClassRelativePath, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getId, getLocale, getLocalizer, getModel, getModelObject, getModelObjectAsString, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResource, getResponse, getSession, getString, getString, getString, getStyle, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnEndRequest, internalOnModelChanged, internalOnModelChanging, isAncestorOf, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onBeginRequest, onEndRequest, onModelChanged, onModelChanging, onSessionAttach, redirectTo, remove, render, renderComponent, renderComponentTag, rendered, replaceComponentTagBody, sameRootModel, sameRootModel, setFlag, setModelObject, setRedirect, setRenderBodyOnly, setResponsePage, setShouldEscapeModelStrings, setVersioned, setVisible, urlFor, visitParents, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Link

public Link(java.lang.String id)
See Also:
Component.Component(String)

Link

public Link(java.lang.String id,
            IModel object)
See Also:
Component.Component(String, IModel)
Method Detail

getAfterDisabledLink

public java.lang.String getAfterDisabledLink()
Gets the insertion string to allow disabled links to look like Disabled link .

Returns:
The insertion string

getAutoEnable

public final boolean getAutoEnable()
Gets whether link should automatically enable/disable based on current page.

Returns:
Whether this link should automatically enable/disable based on current page.

getBeforeDisabledLink

public java.lang.String getBeforeDisabledLink()
Gets the insertion string to allow disabled links to look like Disabled link .

Returns:
The insertion string

getPopupSettings

public final PopupSettings getPopupSettings()
Gets the popup specification. If not-null, a javascript on-click event handler will be generated that opens a new window using the popup properties.

Returns:
the popup specification.

isEnabled

public final boolean isEnabled()
Gets whether this link is enabled.

Returns:
whether this link is enabled.

onClick

public abstract void onClick()
Called when a link is clicked.


onLinkClicked

public final void onLinkClicked()
THIS METHOD IS NOT PART OF THE WICKET API. DO NOT ATTEMPT TO OVERRIDE OR CALL IT. Called when a link is clicked. The implementation of this method is currently to simply call onClick(), but this may be augmented in the future.

Specified by:
onLinkClicked in interface ILinkListener
See Also:
ILinkListener

setAfterDisabledLink

public void setAfterDisabledLink(java.lang.String afterDisabledLink)
Sets the insertion string to allow disabled links to look like Disabled link .

Parameters:
afterDisabledLink - The insertion string

setAutoEnable

public final Link setAutoEnable(boolean autoEnable)
Sets whether this link should automatically enable/disable based on current page.

Parameters:
autoEnable - whether this link should automatically enable/disable based on current page.
Returns:
This

setBeforeDisabledLink

public void setBeforeDisabledLink(java.lang.String beforeDisabledLink)
Sets the insertion string to allow disabled links to look like Disabled link .

Parameters:
beforeDisabledLink - The insertion string

setEnabled

public final Link setEnabled(boolean enabled)
Sets link enabled state.

Parameters:
enabled - The enabled to set.
Returns:
This

setPopupSettings

public final Link setPopupSettings(PopupSettings popupSettings)
Sets the popup specification. If not-null, a javascript on-click event handler will be generated that opens a new window using the popup properties.

Parameters:
popupSettings - the popup specification.
Returns:
This

getOnClickScript

protected java.lang.String getOnClickScript(java.lang.String url)
Parameters:
url - The url for the link
Returns:
Any onClick JavaScript that should be used

getURL

protected java.lang.String getURL()
Gets the url to use for this link.

Returns:
The URL that this link links to

linksTo

protected boolean linksTo(Page page)
Whether this link refers to the given page.

Parameters:
page - A page
Returns:
True if this link goes to the given page

onComponentTag

protected final void onComponentTag(ComponentTag tag)
Handles this link's tag.

Overrides:
onComponentTag in class Component
Parameters:
tag - the component tag
See Also:
Component.onComponentTag(ComponentTag)

internalOnBeginRequest

protected void internalOnBeginRequest()
Description copied from class: Component
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE. Called when a request begins.

Overrides:
internalOnBeginRequest in class Component
See Also:
Component.internalOnBeginRequest()

onComponentTagBody

protected final void onComponentTagBody(MarkupStream markupStream,
                                        ComponentTag openTag)
Renders this link's body.

Overrides:
onComponentTagBody in class MarkupContainer
Parameters:
markupStream - the markup stream
openTag - the open part of this tag
See Also:
Component.onComponentTagBody(MarkupStream, ComponentTag)


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