public class HtmlElement extends XmlElement
final HtmlElement html = new HtmlElement("Test");
html.getBody().addElement("div")
.addText("Hello word!");
html.toResponse(new MockHttpServletResponse(), false);
| Modifier and Type | Class and Description |
|---|---|
static interface |
HtmlElement.Html
Some HTML constants
|
XmlElement.RawEnvelope| Modifier and Type | Field and Description |
|---|---|
protected Charset |
charset
Charset
|
attributes, childrenDEFAULT_INTENDATION, HTML_DOCTYPE, name, REQUIRED_MSG, XML_HEADER| Constructor and Description |
|---|
HtmlElement(Charset charset)
Create new instance with empty html headers
|
HtmlElement(Object title,
CharSequence... cssLinks)
Constructor buliding default html headers with codepage UTF-8
|
HtmlElement(Object title,
Charset charset,
CharSequence... cssLinks)
Generic constructor buliding default html headers
|
| Modifier and Type | Method and Description |
|---|---|
<T extends XmlElement> |
addCssBody(CharSequence css)
Create a new CSS element and return it
|
<T extends XmlElement> |
addCssLink(CharSequence css)
Create a new CSS element and return it
|
<T extends XmlElement> |
addElementToBody(String name)
A shortcut for
HtmlList.getBody().addElement(CharSequence) |
<T extends XmlElement> |
addElementToHead(String name)
A shortcut for
HtmlList.getHead().addElement(CharSequence) |
<T extends XmlElement> |
addJavascriptContent(CharSequence javascript)
Create a new Javascript element and return it
|
<T extends XmlElement> |
addJavascriptLink(boolean defer,
CharSequence... javascriptLink)
Create a new Javascript element and return it
|
<T extends XmlElement> |
getBody()
Returns body element
|
<T extends XmlElement> |
getHead()
Deprecated.
Use the method
addElementToHead(java.lang.String) rather. |
void |
toNiceResponse(Object httpServletResponse)
Render the result with an indentation
|
void |
toResponse(Object httpServletResponse,
boolean noCache)
Render the component to a HTML response
|
void |
toResponse(Object httpServletResponse,
boolean noCache,
boolean indentation)
Render the result
|
String |
toString()
Render the HTML code including header
|
XmlWriter |
toWriter(XmlWriter xmlWriter)
Render the component to a
XmlWriter |
addAttrib, addCDATA, addComment, addElement, addElement, addChild, addRawText, addText, close, getAttribs, getAttributes, getChildren, setAttrib, toWritergetNamepublic HtmlElement(@Nonnull Charset charset)
public HtmlElement(@Nonnull Object title, @Nullable CharSequence... cssLinks)
@Nonnull @Deprecated public <T extends XmlElement> T getHead()
addElementToHead(java.lang.String) rather.@Nonnull public <T extends XmlElement> T getBody()
public <T extends XmlElement> T addElementToHead(@Nonnull String name)
HtmlList.getHead().addElement(CharSequence) name - A name of the new XmlElement is requred.public <T extends XmlElement> T addElementToBody(@Nonnull String name)
HtmlList.getBody().addElement(CharSequence) name - A name of the new XmlElement is requred.public <T extends XmlElement> T addJavascriptLink(boolean defer, @Nonnull CharSequence... javascriptLink)
javascriptLink - URL to Javascriptdefer - A script that will not run until after the page has loadedpublic <T extends XmlElement> T addJavascriptContent(@Nonnull CharSequence javascript)
javascript - Add a javascriptLink linkpublic <T extends XmlElement> T addCssLink(@Nonnull CharSequence css)
css - Add a CSS linkpublic <T extends XmlElement> T addCssBody(@Nonnull CharSequence css)
css - CSS content@Nonnull public String toString() throws IllegalStateException
toString in class XmlElementIllegalStateExceptionpublic final void toResponse(@Nonnull Object httpServletResponse, boolean noCache) throws IOException, IllegalArgumentException
httpServletResponse - Argument type of javax.servlet.http.HttpServletResponse is required.noCache - Add a header attributes to switch off a cache.IOException - An writting error.IllegalArgumentException - Wrong argument typepublic final void toNiceResponse(@Nonnull Object httpServletResponse) throws IOException, IllegalArgumentException
IOExceptionIllegalArgumentExceptionpublic void toResponse(@Nonnull Object httpServletResponse, boolean noCache, boolean indentation) throws IOException, IllegalArgumentException
httpServletResponse - noCache - indentation - IOExceptionIllegalArgumentExceptionpublic XmlWriter toWriter(@Nonnull XmlWriter xmlWriter) throws IOException, IllegalArgumentException
XmlWriterxmlWriter - An instance of the XmlWriter is required.IOException - An writting error.IllegalArgumentException - Wrong argument typeCopyright 2015, Pavel Ponec