Package rsp.dsl
Class Html
- java.lang.Object
-
- rsp.dsl.Html
-
public final class Html extends Object
A HTML tags definitions domain-specific language and related util functions.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_PROPERTIES_NAMESAttributes names which are interpreted by default as properties.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TagDefinitiona(String href, String text, DocumentPartDefinition... children)A HTML <a>, or anchor element of a HTML document.static TagDefinitiona(DocumentPartDefinition... children)A HTML <a> element of a HTML document.static AttributeDefinitionattr(String name)A boolean attribute.static AttributeDefinitionattr(String name, String value)A HTML element's attribute.static AttributeDefinitionattr(String name, String value, boolean isProperty)A HTML element's attribute.static TagDefinitionbody(DocumentPartDefinition... children)A HTML <body> element of a HTML document.static TagDefinitionbutton(DocumentPartDefinition... children)A HTML <button> element of a HTML document.static ElementRefcreateElementRef()Creates reference to a HTML element which can be used as a key for obtaining its element's properties values.static TimerRefcreateTimerRef()Creates a reference to a schedule's timer.static TagDefinitiondiv(String text)A HTML <div> element of a HTML document.static TagDefinitiondiv(DocumentPartDefinition... children)A HTML <div> element of a HTML document.static TagDefinitionform(DocumentPartDefinition... children)A HTML <form> element of a HTML document.static TagDefinitionh1(DocumentPartDefinition... children)A HTML <h1> element of a HTML document.static TagDefinitionh2(DocumentPartDefinition... children)A HTML <h2> element of a HTML document.static TagDefinitionh3(DocumentPartDefinition... children)A HTML <h3> element of a HTML document.static TagDefinitionh4(DocumentPartDefinition... children)A HTML <h4> element of a HTML documentstatic TagDefinitionh5(DocumentPartDefinition... children)A HTML <h5> element of a HTML document.static TagDefinitionh6(DocumentPartDefinition... children)A HTML <h6> element of a HTML document.static TagDefinitionhead(DocumentPartDefinition... children)A HTML <head> element of a HTML document.static TagDefinitionhtml(DocumentPartDefinition... children)A HTML <html> element, the root element of a HTML document.static TagDefinitioninput(DocumentPartDefinition... children)A HTML <input> element of a HTML document.static TagDefinitionlabel(DocumentPartDefinition... children)A HTML <label> element of a HTML document.static TagDefinitionli(String text)A HTML <li> element of a HTML document.static TagDefinitionli(DocumentPartDefinition... children)A HTML <li> element of a HTML document.static TagDefinitionlink(AttributeDefinition... children)A HTML <link> element of a HTML document.static TagDefinitionmeta(AttributeDefinition... children)A HTML <meta> element of a HTML document.static DocumentPartDefinitionof(CompletableFuture<? extends DocumentPartDefinition> completableFutureDefinition)Inserts a definition which is a result of aCompletableFuturecompletion.static SequenceDefinitionof(Supplier<DocumentPartDefinition> itemSupplier)Inserts a definition which is a result of some code execution.static SequenceDefinitionof(Stream<DocumentPartDefinition> items)Inserts a zero or more definitions provided as a stream.static TagDefinitionol(DocumentPartDefinition... children)A HTML <ol> element of a HTML document.static EventDefinitionon(String eventType, boolean preventDefault, Consumer<rsp.page.EventContext> handler)A DOM event handler definition.static EventDefinitionon(String eventType, Consumer<rsp.page.EventContext> handler)A DOM event handler definition.static TagDefinitionp(String text)A HTML <p> element of a HTML document.static TagDefinitionp(DocumentPartDefinition... children)A HTML <p> element of a HTML document.static AttributeDefinitionprop(String name, String value)An element's property attribute.static TagDefinitionspan(String text)A HTML <span> element of a HTML document.static TagDefinitionspan(DocumentPartDefinition... children)A HTML <span> element of a HTML document.static StyleDefinitionstyle(String name, String value)An element's inline style.static TagDefinitiontable(DocumentPartDefinition... children)A HTML <table> element of a HTML document.static TagDefinitiontag(String name, DocumentPartDefinition... children)An arbitrary HTML element.static TagDefinitiontbody(DocumentPartDefinition... children)A HTML <tbody> element of a HTML document.static TagDefinitiontd(String text)A HTML <td> element of a HTML document.static TagDefinitiontd(DocumentPartDefinition... children)A HTML <td> element of a HTML document.static TextDefinitiontext(Object obj)An element's text content, for a input class other than qString.static TextDefinitiontext(String text)An element's text content.static TagDefinitionth(String text)A HTML <th> element of a HTML document.static TagDefinitionth(DocumentPartDefinition... children)A HTML <th> element of a HTML document.static TagDefinitionthead(DocumentPartDefinition... children)A HTML <thead> element of a HTML document.static TagDefinitiontitle(String text)A HTML <title> element of a HTML document.static TagDefinitiontr(DocumentPartDefinition... children)A HTML <tr> element of a HTML document.static TagDefinitionul(DocumentPartDefinition... children)A HTML <ul> element of a HTML document.static DocumentPartDefinitionwhen(boolean condition, Supplier<DocumentPartDefinition> then)A lazy form of conditional function.static DocumentPartDefinitionwhen(boolean condition, DocumentPartDefinition then)Inserts a document part definition provided as an argument if condition is true, otherwise inserts an empty definition.static WindowRefwindow()Provides a definition of a browsers' window object.
-
-
-
Field Detail
-
DEFAULT_PROPERTIES_NAMES
public static final String DEFAULT_PROPERTIES_NAMES
Attributes names which are interpreted by default as properties.- See Also:
attr(String, String), Constant Field Values
-
-
Method Detail
-
tag
public static TagDefinition tag(String name, DocumentPartDefinition... children)
An arbitrary HTML element.- Parameters:
name- an element namechildren- descendants definitions of this element- Returns:
- a tag definition
-
attr
public static AttributeDefinition attr(String name, String value, boolean isProperty)
A HTML element's attribute.- Parameters:
name- an attribute namevalue- an attribute valueisProperty- true if this attribute should be interpreted as a property, false otherwise- Returns:
- an attribute definition
-
prop
public static AttributeDefinition prop(String name, String value)
An element's property attribute.- Parameters:
name- a property namevalue- a property value- Returns:
- a property definition
-
attr
public static AttributeDefinition attr(String name, String value)
A HTML element's attribute. This attribute is interpreted as a property if its name is one of the properties by default: "autofocus, autoplay, async, checked, controls, defer, disabled, hidden, loop, multiple, open, readonly, required, scoped, selected, value".- Parameters:
name- an attribute namevalue- an attribute value- Returns:
- an attribute definition
-
attr
public static AttributeDefinition attr(String name)
A boolean attribute.- Parameters:
name- an attribute name- Returns:
- an attribute definition
-
on
public static EventDefinition on(String eventType, Consumer<rsp.page.EventContext> handler)
A DOM event handler definition.- Parameters:
eventType- an event namehandler- an event handler- Returns:
- a DOM event handler definition
-
on
public static EventDefinition on(String eventType, boolean preventDefault, Consumer<rsp.page.EventContext> handler)
A DOM event handler definition.- Parameters:
eventType- an event namepreventDefault- true if the event does not get explicitly handled, its default action should not be taken as it normally would be, false otherwisehandler- an event handler- Returns:
- a DOM event handler definition
-
style
public static StyleDefinition style(String name, String value)
An element's inline style.- Parameters:
name- a style namevalue- a style value- Returns:
- an inline style definition
-
text
public static TextDefinition text(String text)
An element's text content.- Parameters:
text- a text as aString- Returns:
- a text node definition
-
text
public static TextDefinition text(Object obj)
An element's text content, for a input class other than qString.- Parameters:
obj- an arbitrary object to be converted to text using itsObject.toString()method- Returns:
- a text node definition
-
html
public static TagDefinition html(DocumentPartDefinition... children)
A HTML <html> element, the root element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
body
public static TagDefinition body(DocumentPartDefinition... children)
A HTML <body> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
head
public static TagDefinition head(DocumentPartDefinition... children)
A HTML <head> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
title
public static TagDefinition title(String text)
A HTML <title> element of a HTML document.- Parameters:
text- a document's title text- Returns:
- a tag definition
-
link
public static TagDefinition link(AttributeDefinition... children)
A HTML <link> element of a HTML document.- Parameters:
children- the element's attributes- Returns:
- a tag definition
-
meta
public static TagDefinition meta(AttributeDefinition... children)
A HTML <meta> element of a HTML document.- Parameters:
children- the element's attributes- Returns:
- a tag definition
-
h1
public static TagDefinition h1(DocumentPartDefinition... children)
A HTML <h1> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
h2
public static TagDefinition h2(DocumentPartDefinition... children)
A HTML <h2> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
h3
public static TagDefinition h3(DocumentPartDefinition... children)
A HTML <h3> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
h4
public static TagDefinition h4(DocumentPartDefinition... children)
A HTML <h4> element of a HTML document- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
h5
public static TagDefinition h5(DocumentPartDefinition... children)
A HTML <h5> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
h6
public static TagDefinition h6(DocumentPartDefinition... children)
A HTML <h6> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
div
public static TagDefinition div(DocumentPartDefinition... children)
A HTML <div> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
div
public static TagDefinition div(String text)
A HTML <div> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
a
public static TagDefinition a(DocumentPartDefinition... children)
A HTML <a> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
a
public static TagDefinition a(String href, String text, DocumentPartDefinition... children)
A HTML <a>, or anchor element of a HTML document.- Parameters:
href- the URL that the hyperlink points totext- the link's destination text contentchildren- other descendants definitions of this element- Returns:
- a tag definition
-
p
public static TagDefinition p(DocumentPartDefinition... children)
A HTML <p> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
p
public static TagDefinition p(String text)
A HTML <p> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
span
public static TagDefinition span(DocumentPartDefinition... children)
A HTML <span> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
span
public static TagDefinition span(String text)
A HTML <span> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
form
public static TagDefinition form(DocumentPartDefinition... children)
A HTML <form> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
input
public static TagDefinition input(DocumentPartDefinition... children)
A HTML <input> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
button
public static TagDefinition button(DocumentPartDefinition... children)
A HTML <button> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
ul
public static TagDefinition ul(DocumentPartDefinition... children)
A HTML <ul> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
ol
public static TagDefinition ol(DocumentPartDefinition... children)
A HTML <ol> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
li
public static TagDefinition li(DocumentPartDefinition... children)
A HTML <li> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
li
public static TagDefinition li(String text)
A HTML <li> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
table
public static TagDefinition table(DocumentPartDefinition... children)
A HTML <table> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
thead
public static TagDefinition thead(DocumentPartDefinition... children)
A HTML <thead> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
tbody
public static TagDefinition tbody(DocumentPartDefinition... children)
A HTML <tbody> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
th
public static TagDefinition th(DocumentPartDefinition... children)
A HTML <th> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
th
public static TagDefinition th(String text)
A HTML <th> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
tr
public static TagDefinition tr(DocumentPartDefinition... children)
A HTML <tr> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
td
public static TagDefinition td(DocumentPartDefinition... children)
A HTML <td> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
td
public static TagDefinition td(String text)
A HTML <td> element of a HTML document.- Parameters:
text- text content- Returns:
- a tag definition
-
label
public static TagDefinition label(DocumentPartDefinition... children)
A HTML <label> element of a HTML document.- Parameters:
children- descendants definitions of this element- Returns:
- a tag definition
-
of
public static SequenceDefinition of(Stream<DocumentPartDefinition> items)
Inserts a zero or more definitions provided as a stream.- Parameters:
items- aStreamof definitions- Returns:
- a document part definition representing a sequence of definitions
-
of
public static SequenceDefinition of(Supplier<DocumentPartDefinition> itemSupplier)
Inserts a definition which is a result of some code execution. This functions allows to mix declarative DOM tree definitions and code fragments.- Parameters:
itemSupplier- a code block- Returns:
- a result definition
-
of
public static DocumentPartDefinition of(CompletableFuture<? extends DocumentPartDefinition> completableFutureDefinition)
Inserts a definition which is a result of aCompletableFuturecompletion.- Parameters:
completableFutureDefinition- an asynchronous computation of a definition- Returns:
- a result definition
-
when
public static DocumentPartDefinition when(boolean condition, DocumentPartDefinition then)
Inserts a document part definition provided as an argument if condition is true, otherwise inserts an empty definition.- Parameters:
condition- a condition to checkthen- a definition which may be inserted- Returns:
- a result definition
-
when
public static DocumentPartDefinition when(boolean condition, Supplier<DocumentPartDefinition> then)
A lazy form of conditional function. Inserts a document part definition provided as in aSupplierif condition is true, otherwise inserts an empty definition.- Parameters:
condition- a condition to checkthen- aSupplierof a definition which may be inserted- Returns:
- a result definition
-
window
public static WindowRef window()
Provides a definition of a browsers' window object.- Returns:
- a window object definition
-
createElementRef
public static ElementRef createElementRef()
Creates reference to a HTML element which can be used as a key for obtaining its element's properties values.- Returns:
- a reference object
- See Also:
EventContext.props(ElementRef)
-
createTimerRef
public static TimerRef createTimerRef()
Creates a reference to a schedule's timer.- Returns:
- a reference object
- See Also:
EventContext.schedule(Runnable, TimerRef, int, TimeUnit),EventContext.scheduleAtFixedRate(Runnable, TimerRef, int, int, TimeUnit)
-
-