Class Link
java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.components.navigation.Link
- All Implemented Interfaces:
Component
Hyperlink component with URL-scheme validation and HTMX helpers.
Mutable and not thread-safe. Configure and render within a request-scoped lifecycle. For reuse, stop mutating shared instances and render stable structures with per-request context data.
Security boundary: withHref(String) and constructor validate href schemes and allow
only http, https, mailto, tel, or relative URLs.
Classification trims boundary C0/ASCII space, removes TAB/LF/CR, and folds ASCII case,
independently of locale; the original value is stored and attribute-encoded unchanged.
This is not destination authorization. Generic attribute replacement and HTMX endpoints
do not use this href policy.
-
Field Summary
Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LinkFactory for a link.getHref()Returns current href value.getText()Returns current text value.Convenience fortarget="_blank".Appends child content inside the anchor.Replaces class attribute.Sets href after allowlist validation.Setshx-getto an application-controlled or separately endpoint-validated URL.withHxPost(String url) Setshx-postto an application-controlled or separately endpoint-validated URL.withHxPushUrl(boolean pushUrl) Setshx-push-url.Tags this HTMX request to scroll the swapped target fragment to top after settle.withHxSwap(String swap) Setshx-swap.withHxTarget(String target) Setshx-target.Sets id attribute.withTarget(String target) Sets target attribute.Methods inherited from class HtmlTag
addClass, addStyle, addTrustedStyle, getChildrenStream, getId, hxDelete, hxGet, hxInclude, hxPatch, hxPost, hxPushUrl, hxPut, hxScrollTargetTop, hxSwap, hxTarget, hxTrigger, render, withAttribute, withInnerText, withInnerText, withMaxWidth, withMinWidth, withUnsafeHtml, withWidth
-
Constructor Details
-
Link
Creates a link with validated href and escaped text content.- Parameters:
href- target URL (allowlisted schemes or relative path)text- link text- Throws:
IllegalArgumentException- when scheme is disallowed
-
-
Method Details
-
create
-
getHref
-
getText
-
withId
-
withTarget
-
openInNewTab
-
withHref
Sets href after allowlist validation.- Parameters:
href- the target URL- Returns:
- this link
- Throws:
IllegalArgumentException- when href scheme is disallowed
-
withClass
-
withHxGet
-
withHxPost
-
withHxTarget
-
withHxSwap
-
withHxPushUrl
Setshx-push-url.- Parameters:
pushUrl- whether browser URL should be pushed- Returns:
- this link
-
withHxScrollTargetTop
Tags this HTMX request to scroll the swapped target fragment to top after settle.- Returns:
- this link
-
withChild
-