public class HtmlElement extends XmlElement
final HtmlElement html = new HtmlElement("Test");
html.getBody().addElement("div")
.addText("Hello word!");
HttpServletResponse response = new MockHttpServletResponse();
html.toResponse(response, false);
| Modifier and Type | Class and Description |
|---|---|
static interface |
HtmlElement.Html
Some HTML constants
|
XmlElement.RawEnvelope| Modifier and Type | Field and Description |
|---|---|
static String |
HEADER
XML header
|
protected Charset |
charset
Charset
|
nameCDATA_BEG, CDATA_END, COMMENT_BEG, COMMENT_END, CHAR_NEW_LINE, CHAR_SPACE, XML_2QUOT, XML_AMP, XML_GT, XML_LT, XML_QUOT| Constructor and Description |
|---|
HtmlElement(CharSequence title)
Constructor for codepage UTF-8
|
HtmlElement(CharSequence title,
Charset charset)
Generaic Constructor
|
| Modifier and Type | Method and Description |
|---|---|
<T extends Element> |
addCssBody(String css)
Create a new CSS element and return it
|
<T extends Element> |
addCssLink(String css)
Create a new CSS element and return it
|
<T extends Element> |
addElementToBody(CharSequence name)
A shortcut for
HtmlList.getBody().addElement(CharSequence) |
<T extends Element> |
addElementToHead(CharSequence name)
A shortcut for
HtmlList.getHead().addElement(CharSequence) |
<T extends Element> |
getBody()
Returns body element
|
<T extends Element> |
getHead()
Returns header element
|
void |
toResponse(Object httpServletResponse,
boolean noCache)
Render the component to a HTML response
|
String |
toString()
Render the HTML code including header
|
addAttrib, addCDATA, addComment, addElement, addElement, addRawText, addText, addTextWithSpace, getAttribs, getChildren, toWriter, writeValuepublic static final String HEADER
public HtmlElement(@Nonnull CharSequence title)
public HtmlElement(@Nonnull CharSequence title, @Nonnull Charset charset)
public <T extends Element> T addElementToHead(@Nonnull CharSequence name)
HtmlList.getHead().addElement(CharSequence) name - A name of the new XmlElement is requred.public <T extends Element> T addElementToBody(@Nonnull CharSequence name)
HtmlList.getBody().addElement(CharSequence) name - A name of the new XmlElement is requred.public <T extends Element> T addCssLink(String css)
css - Add a CSS linkpublic <T extends Element> T addCssBody(@Nullable String css)
css - CSS content@Nonnull public String toString() throws IllegalStateException
toString in class XmlElementIllegalStateExceptionpublic 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 typeCopyright 2019-2022, Pavel Ponec