Class ExternalLink
- 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.link.ExternalLink
-
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,Component>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
public class ExternalLink extends AbstractLink
A simple anchor link (<a href="http://url">) pointing to any URL. Usually this is used for links to destinations outside of Wicket.
Note: in the case when the support for cookies in the browser is disabled the user's jsessionid will leak in the 'Referrer' header after clicking this link. If this is a problem for the application then better use a
Link
which redirects to a shared resource (seeWebApplication.mountResource(String, org.apache.wicket.request.resource.ResourceReference)
, e.g. "/myapp/redirecting-resource?url=...") which on its side redirects to the new URL usingRedirectToUrlException
. Another option is to userel="noreferrer"
attribute in your markup but this will work only in the modern browsers (supporting HTML5 standard).- Author:
- Juergen Donnerstag
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Constructor Summary
Constructors Constructor Description ExternalLink(String id, String href)
Constructor.ExternalLink(String id, String href, String label)
Constructor.ExternalLink(String id, IModel<String> href)
Constructor.ExternalLink(String id, IModel<String> href, IModel<?> label)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PopupSettings
getPopupSettings()
Gets the popup specification.boolean
isContextRelative()
protected void
onComponentTag(ComponentTag tag)
Processes the component tag.void
renderHead(IHeaderResponse response)
Render to the web response whatever the component wants to contribute to the head section.ExternalLink
setContextRelative(boolean contextRelative)
Set to true if this link should be automatically prepended with ../ to make it relative to the context root.ExternalLink
setPopupSettings(PopupSettings popupSettings)
Sets the popup specification.-
Methods inherited from class org.apache.wicket.markup.html.link.AbstractLink
disableLink, getBody, onComponentTagBody, onDetach, setBody
-
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
-
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, 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, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ExternalLink
public ExternalLink(String id, String href, String label)
Constructor.- Parameters:
id
- See Componenthref
- the href attribute to setlabel
- the label (body)
-
ExternalLink
public ExternalLink(String id, String href)
Constructor.- Parameters:
id
- The name of this componenthref
- the href attribute to set
-
ExternalLink
public ExternalLink(String id, IModel<String> href)
Constructor.- Parameters:
id
- The name of this componenthref
- the href attribute to set
-
ExternalLink
public ExternalLink(String id, IModel<String> href, IModel<?> label)
Constructor.- Parameters:
id
- See Componenthref
- the href attribute to setlabel
- the label (body)
-
-
Method Detail
-
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.
-
setPopupSettings
public final ExternalLink 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
-
onComponentTag
protected void onComponentTag(ComponentTag tag)
Processes the component tag.- Overrides:
onComponentTag
in classComponent
- Parameters:
tag
- Tag to modify- See Also:
Component.onComponentTag(org.apache.wicket.markup.ComponentTag)
-
renderHead
public void renderHead(IHeaderResponse response)
Description copied from class:Component
Render to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHead
in interfaceIHeaderContributor
- Overrides:
renderHead
in classComponent
- Parameters:
response
- Response object
-
isContextRelative
public boolean isContextRelative()
- Returns:
- True if this link is automatically prepended with ../ to make it relative to the context root.
-
setContextRelative
public ExternalLink setContextRelative(boolean contextRelative)
Set to true if this link should be automatically prepended with ../ to make it relative to the context root.- Parameters:
contextRelative
-- Returns:
- This for chaining
-
-