Interface HstLink
HstLink is the object representing a link. The getPath()
return you the value of the link, and getPathElements()
returns you the path splitted on "/"'s. The String[] version is more practical because the HttpServletResponse.encodeURL(String)
also encodes slashes.
Furthermore, the HstSite
that the link is meant for is accessible through this HstLink, because it is needed if the link is
out of the scope of the current HstSite. The HstSite can access the VirtualHost
through which
in turn even links to different hosts can be created.
Note do *not* use HstLink
objects in caches and do *not* store them on http sessions (for example last
visited URLs). HstLink objects hold references to the backing hst model, which should be by accident held from
garbage collection due to objects retaining it (by accident)
-
Method Summary
Modifier and TypeMethodDescriptiongetMount()
getPath()
Note: This is *not* a url!String[]
Returns the subPath of thisHstLink
object.boolean
WhenisContainerResource()
returnstrue
, the resulting URL will be webapp relative and not relative toMount.getMountPath()
boolean
When for example for some bean the (real) link cannot be created through the HstLinkCreator, a HstLink can be returned with a path that is for example from some configured property like '/pagenotfound'.boolean
void
setContainerResource
(boolean containerResource) void
setNotFound
(boolean notFound) void
(re)-sets the path of the HstLinkvoid
setSubPath
(String subPath) sets thesubPath
of thisHstLink
.toUrlForm
(HstRequestContext requestContext, boolean fullyQualified)
-
Method Details
-
getPath
String getPath()Note: This is *not* a url!- Returns:
- the path of this HstLink. Note: This is *not* a url! The value never starts or ends with a slash /
-
setPath
(re)-sets the path of the HstLink- Parameters:
path
-
-
getSubPath
String getSubPath()Returns the subPath of thisHstLink
object. This part will be appended to thegetPath()
and delimited by./
. It will be before the queryString. Note that an emptyString
subPath
will result in a URL having a./
appended: An emptysubPath
is thus something different then anull
subPath
.- Returns:
- the subPath of this
HstLink
object.
-
setSubPath
sets thesubPath
of thisHstLink
. Note that setting thesubPath
to an emptyString
will result in a URL having a./
appended: An emptysubPath
is thus something different then anull
subPath
.- Parameters:
subPath
-
-
isContainerResource
boolean isContainerResource()When
isContainerResource()
returnstrue
, the resulting URL will be webapp relative and not relative toMount.getMountPath()
When
isContainerResource()
returnsfalse
, the resulting URL WILL include theMount.getMountPath()
after the webapp relative part (context path).- Returns:
true
when the HstLink represents a container resource, like a repository binary, a web file or a static css file served by the container.
-
setContainerResource
void setContainerResource(boolean containerResource) - Parameters:
containerResource
- sets whether thisHstLink
is acontainerResource
or not.- See Also:
-
toUrlForm
- Parameters:
requestContext
-fullyQualified
- if true, the returned link is a fully qualified URL, in other words including http/https etc- Returns:
- the url form of this HstLink, which is a url
-
getPathElements
String[] getPathElements()- Returns:
- the path elements of this HstLink, which is the
getPath()
splitted on slashes
-
getMount
Mount getMount()- Returns:
- the
Mount
that can represent this link. This might be anMount
which is a different one then theMount
the link was created in. This could result in a cross-domain (different hostname) link being created, depending on the backingMount.getVirtualHost()
. If noMount
is set,null
can be returned
-
getHstSiteMapItem
HstSiteMapItem getHstSiteMapItem()- Returns:
- the
HstSiteMapItem
that matches thisHstLink
ornull
if thisHstLink
cannot be matched to anyHstSiteMapItem
-
isNotFound
boolean isNotFound()When for example for some bean the (real) link cannot be created through the HstLinkCreator, a HstLink can be returned with a path that is for example from some configured property like '/pagenotfound'. If this method returnstrue
it indicates that the link is some hardcoded path for beans that cannot be linked to- Returns:
true
when this HstLink indicates to be a link that is actually a notFound link
-
setNotFound
void setNotFound(boolean notFound) - Parameters:
notFound
- true whether this HstLink is actually a notFound link
-
representsIndex
boolean representsIndex()- Returns:
true
if thisHstLink
was the result of a document/folder being matched to anHstNodeTypes.INDEX
sitemap item
-