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
|
attributes, children, name
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 XmlElement> |
addCssBody(String css)
Create a new CSS element and return it
|
<T extends XmlElement> |
addCssLink(String css)
Create a new CSS element and return it
|
<T extends XmlElement> |
addElementToBody(CharSequence name)
A shortcut for
HtmlList.getBody().addElement(CharSequence) |
<T extends XmlElement> |
addElementToHead(CharSequence name)
A shortcut for
HtmlList.getHead().addElement(CharSequence) |
<T extends XmlElement> |
getBody()
Returns body element
|
<T extends XmlElement> |
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
|
void |
toWriter(XmlWriter xmlWriter)
Render the component to a
XmlWriter |
addAttrib, addCDATA, addComment, addElement, addElement, addChild, addRawText, addText, addTextWithSpace, getAttribs, getAttributes, getChildren, getName, toWriter
public static final String HEADER
public HtmlElement(@Nonnull CharSequence title)
public HtmlElement(@Nonnull CharSequence title, @Nonnull Charset charset)
@Nonnull public <T extends XmlElement> T getHead()
@Nonnull public <T extends XmlElement> T getBody()
public <T extends XmlElement> T addElementToHead(@Nonnull CharSequence name)
HtmlList.getHead().addElement(CharSequence)
name
- A name of the new XmlElement is requred.public <T extends XmlElement> T addElementToBody(@Nonnull CharSequence name)
HtmlList.getBody().addElement(CharSequence)
name
- A name of the new XmlElement is requred.public <T extends XmlElement> T addCssLink(String css)
css
- Add a CSS linkpublic <T extends XmlElement> T addCssBody(@Nullable String css)
css
- CSS content@Nonnull public String toString() throws IllegalStateException
toString
in class XmlElement
IllegalStateException
public 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 void toWriter(@Nonnull XmlWriter xmlWriter) throws IOException, IllegalArgumentException
XmlWriter
xmlWriter
- An instance of the XmlWriter is required.IOException
- An writting error.IllegalArgumentException
- Wrong argument typeCopyright 2019-2022, Pavel Ponec