Package org.ujorm.tools.web
Class HtmlElement
java.lang.Object
org.ujorm.tools.web.AbstractHtmlElement
org.ujorm.tools.web.HtmlElement
- All Implemented Interfaces:
Closeable,AutoCloseable,Html,ApiElement<Element>
The root of HTML elements
Usage
ServletResponse response = new ServletResponse();
try (HtmlElement html = HtmlElement.of(response)) {
html.addBody().addHeading("Hello!");
}
assertTrue(response.toString().contains("<h1>Hello!</h1>"));
For more information see the
next sample.-
Field Summary
Fields inherited from interface org.ujorm.tools.web.Html
A, A_ACTION, A_ALT, A_CELLPADDING, A_CELLSPACING, A_CLASS, A_COLS, A_COLSPAN, A_CONTENT, A_FOR, A_HREF, A_HTTP_EQUIV, A_CHARSET, A_CHECKED, A_ID, A_LANG, A_LANGUAGE, A_MAXLENGTH, A_MEDIA, A_METHOD, A_NAME, A_ONCLICK, A_PLACEHOLDER, A_READONLY, A_REL, A_ROWS, A_ROWSPAN, A_SELECTED, A_SRC, A_STYLE, A_TARGET, A_TITLE, A_TYPE, A_VALUE, BODY, BR, BUTTON, DIV, FIELDSET, FORM, H1, H2, H3, HEAD, HEADING_PREFIX, HR, HTML, IMAGE, INPUT, LABEL, LEGEND, LI, LINK, META, OL, OPTION, P, PRE, SCRIPT, SELECT, SPAN, STYLE, TABLE, TBODY, TD, TEXT_AREA, TH, THEAD, TITLE, TR, UL, V_BLANK, V_GET, V_HIDDEN, V_CHECKBOX, V_PASSWORD, V_POST, V_RESET, V_STYLESHEET, V_SUBMIT, V_TEXT, V_TEXT_CSS -
Constructor Summary
ConstructorsConstructorDescriptionHtmlElement(@NotNull ApiElement root, @NotNull HtmlConfig config, @NotNull Appendable writer) HtmlElement(@NotNull HtmlConfig config, @NotNull Appendable writer) -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull HtmlElementniceOf(@NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull CharSequence title, @NotNull Appendable response, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull CharSequence title, @NotNull Appendable response, @NotNull Charset charset, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull String title, @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull String title, @NotNull Appendable response, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull String title, @NotNull HttpContext context, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementniceOf(@NotNull HttpContext context, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementof(@NotNull Appendable writer, @NotNull HtmlConfig myConfig) Create a root element for a required element name.static @NotNull HtmlElementof(@NotNull CharSequence title, @NotNull Appendable response, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementof(@NotNull CharSequence title, @NotNull Appendable response, @NotNull Charset charset, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersstatic @NotNull HtmlElementof(@NotNull HttpContext context, @NotNull HtmlConfig myConfig) Create a root element for a required element name.static @NotNull HtmlElementof(@Nullable HtmlConfig config) Create new instance with empty HTML headersstatic @NotNull HtmlElementofResponse(@NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @Nullable HtmlConfig config) Create a new instance with empty HTML headers, The MAIN servlet factory method.static @NotNull HtmlElementofResponse(@NotNull String title, @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull CharSequence... cssLinks) Create new instance with empty HTML headersMethods inherited from class org.ujorm.tools.web.AbstractHtmlElement
addBody, addCDATA, addComment, addCssBodies, addCssBody, addCssLink, addCssLinks, addElement, addHead, addJavascriptBody, addJavascriptLink, addJavascriptLinks, addRawText, addText, addTextTemplated, close, getBody, getConfig, getHead, getName, getTitle, next, niceOfResponse, niceOfResponse, ofServlet, ofServlet, original, setAttribute, then, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ujorm.tools.xml.ApiElement
setAttrib
-
Constructor Details
-
HtmlElement
-
HtmlElement
public HtmlElement(@NotNull @NotNull ApiElement root, @NotNull @NotNull HtmlConfig config, @NotNull @NotNull Appendable writer)
-
-
Method Details
-
of
@NotNull public static @NotNull HtmlElement of(@NotNull @NotNull Appendable writer, @NotNull @NotNull HtmlConfig myConfig) throws IllegalStateException Create a root element for a required element name. The MAIN factory method.- Throws:
IllegalStateException
-
of
@NotNull public static @NotNull HtmlElement of(@NotNull @NotNull HttpContext context, @NotNull @NotNull HtmlConfig myConfig) Create a root element for a required element name. The MAIN factory method. -
ofResponse
@NotNull public static @NotNull HtmlElement ofResponse(@NotNull @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @Nullable @Nullable HtmlConfig config) Create a new instance with empty HTML headers, The MAIN servlet factory method.- Throws:
IllegalStateException- IO exceptions- See Also:
-
ofResponse
@NotNull public static @NotNull HtmlElement ofResponse(@NotNull @NotNull String title, @NotNull @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
of
@NotNull public static @NotNull HtmlElement of(@NotNull @NotNull CharSequence title, @NotNull @NotNull Appendable response, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
of
@NotNull public static @NotNull HtmlElement of(@NotNull @NotNull CharSequence title, @NotNull @NotNull Appendable response, @NotNull @NotNull Charset charset, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull CharSequence title, @NotNull @NotNull Appendable response, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull CharSequence title, @NotNull @NotNull Appendable response, @NotNull @NotNull Charset charset, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull String title, @NotNull @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull jakarta.servlet.http.HttpServletResponse httpServletResponse, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull String title, @NotNull @NotNull HttpContext context, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull HttpContext context, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
niceOf
@NotNull public static @NotNull HtmlElement niceOf(@NotNull @NotNull String title, @NotNull @NotNull Appendable response, @NotNull @NotNull CharSequence... cssLinks) Create new instance with empty HTML headers- Throws:
IllegalStateException- IO exceptions- See Also:
-
of
@NotNull public static @NotNull HtmlElement of(@Nullable @Nullable HtmlConfig config) throws IllegalStateException Create new instance with empty HTML headers- Parameters:
config- Html configuration- Returns:
- An instance of the HtmlPage
- Throws:
IllegalStateException- IO exceptions
-