Package rsp.dsl

Class Html


  • public final class Html
    extends Object
    A HTML tags definitions domain-specific language and related util functions.
    • Method Detail

      • tag

        public static TagDefinition tag​(String name,
                                        DocumentPartDefinition... children)
        An arbitrary HTML element.
        Parameters:
        name - an element name
        children - 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 name
        value - an attribute value
        isProperty - 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 name
        value - a property value
        Returns:
        a property 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 name
        handler - 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 name
        preventDefault - true if the event does not get explicitly handled, its default action should not be taken as it normally would be, false otherwise
        handler - 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 name
        value - 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 a String
        Returns:
        a text node definition
      • text

        public static TextDefinition text​(Object obj)
        An element's text content, for a input class other than q String.
        Parameters:
        obj - an arbitrary object to be converted to text using its Object.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 to
        text - the link's destination text content
        children - 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 - a Stream of 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
      • 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 check
        then - 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 a Supplier if condition is true, otherwise inserts an empty definition.
        Parameters:
        condition - a condition to check
        then - a Supplier of 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)