Class Base<T extends Base<T>>

java.lang.Object
com.oorian.html.Element<T>
com.oorian.html.elements.Base<T>
All Implemented Interfaces:
HeadElement

public class Base<T extends Base<T>> extends Element<T> implements HeadElement
Represents an HTML <base> element for specifying default URL and target.

The Base element specifies the base URL and/or target for all relative URLs in a document. There can be at most one <base> element in a document, and it must be inside the <head> element.

Features:

  • Sets base URL for all relative URLs in the document
  • Defines default target for all hyperlinks and forms
  • Must be placed within the head element
  • Only one base element allowed per document

Usage:


 Base base = new Base();
 base.setHref("https://www.example.com/");
 base.setTarget(Target.BLANK);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Base

      public Base()
      Constructs an empty <base> element.
  • Method Details

    • setHref

      public final T setHref(String url)
      Sets the base URL for all relative URLs in the document.

      If the URL starts with "/" (absolute path within the application), the servlet context path will be automatically prepended.

      Parameters:
      url - The base URL.
      Returns:
      This element for method chaining.
    • setTarget

      public final T setTarget(Target target)
      Sets the default target using the Target enum.
      Parameters:
      target - The default browsing context for navigation.
      Returns:
      This element for method chaining.
    • setTarget

      public final T setTarget(String target)
      Sets the default target for all hyperlinks and forms in the document.

      Specifies the default browsing context in which to display linked resources. Values include "_self" (same context), "_blank" (new tab/window), "_parent" (parent context), and "_top" (top-level context).

      Parameters:
      target - The default browsing context.
      Returns:
      This element for method chaining.