Class | Description |
---|---|
A |
DTO for an HTML <a>
element.
|
Abbr |
DTO for an HTML <abbr>
element.
|
Address |
DTO for an HTML <address>
element.
|
Area |
DTO for an HTML <area>
element.
|
Article |
DTO for an HTML <article>
element.
|
Aside |
DTO for an HTML <aside>
element.
|
Audio |
DTO for an HTML <audio>
element.
|
B |
DTO for an HTML <b>
element.
|
Base |
DTO for an HTML <base>
element.
|
Bdi |
DTO for an HTML <bdi>
element.
|
Bdo |
DTO for an HTML <bdo>
element.
|
Blockquote |
DTO for an HTML <blockquote>
element.
|
Body |
DTO for an HTML <body>
element.
|
Br |
DTO for an HTML <br>
element.
|
Button |
DTO for an HTML <button>
element.
|
Canvas |
DTO for an HTML <canvas>
element.
|
Caption |
DTO for an HTML <caption>
element.
|
Cite |
DTO for an HTML <cite>
element.
|
Code |
DTO for an HTML <code>
element.
|
Col |
DTO for an HTML <col>
element.
|
Colgroup |
DTO for an HTML <colgroup>
element.
|
Data |
DTO for an HTML <data>
element.
|
Datalist |
DTO for an HTML <datalist>
element.
|
Dd |
DTO for an HTML <dd>
element.
|
Del |
DTO for an HTML <del>
element.
|
Dfn |
DTO for an HTML <dfn>
element.
|
Div |
DTO for an HTML <div>
element.
|
Dl |
DTO for an HTML <dl>
element.
|
Dt |
DTO for an HTML <dt>
element.
|
Em |
DTO for an HTML <em>
element.
|
Embed |
DTO for an HTML <embed>
element.
|
Fieldset |
DTO for an HTML <fieldset>
element.
|
Figcaption |
DTO for an HTML <figcaption>
element.
|
Figure |
DTO for an HTML <figure>
element.
|
Footer |
DTO for an HTML <footer>
element.
|
Form |
DTO for an HTML <form>
element.
|
H1 |
DTO for an HTML <h1>
element.
|
H2 |
DTO for an HTML <h2>
element.
|
H3 |
DTO for an HTML <h3>
element.
|
H4 |
DTO for an HTML <h4>
element.
|
H5 |
DTO for an HTML <h5>
element.
|
H6 |
DTO for an HTML <h6>
element.
|
Head |
DTO for an HTML <head>
element.
|
Header |
DTO for an HTML <header>
element.
|
Hr |
DTO for an HTML <hr>
element.
|
Html |
DTO for an HTML <html>
element.
|
HtmlBeanDictionary |
Defines the Java classes that make up the HTML DTO type dictionary.
|
HtmlBuilder |
Various useful static methods for creating HTML elements.
|
HtmlElement |
Superclass for all HTML elements.
|
HtmlElementContainer |
A subclass of HTML elements that contain only other elements, not text.
|
HtmlElementMixed |
A subclass of HTML elements that contain mixed content (elements and text).
|
HtmlElementRawText |
A subclass of HTML elements that contain raw text
only.
|
HtmlElementText |
A subclass of HTML elements that contain text only.
|
HtmlElementVoid |
A subclass of HTML elements that have no content or end tags.
|
I |
DTO for an HTML <i>
element.
|
Iframe |
DTO for an HTML <iframe>
element.
|
Img |
DTO for an HTML <img>
element.
|
Input |
DTO for an HTML <input>
element.
|
Ins |
DTO for an HTML <ins>
element.
|
Kbd |
DTO for an HTML <kbd>
element.
|
Keygen |
DTO for an HTML <keygen>
element.
|
Label |
DTO for an HTML <label>
element.
|
Legend |
DTO for an HTML <legend>
element.
|
Li |
DTO for an HTML <li>
element.
|
Link |
DTO for an HTML <link>
element.
|
Main |
DTO for an HTML <main>
element.
|
Map |
DTO for an HTML <map>
element.
|
Mark |
DTO for an HTML <mark>
element.
|
Meta |
DTO for an HTML <meta>
element.
|
Meter |
DTO for an HTML <meter>
element.
|
Nav |
DTO for an HTML <nav>
element.
|
Noscript |
DTO for an HTML <noscript>
element.
|
Object2 |
DTO for an HTML <object>
element.
|
Ol |
DTO for an HTML <ol>
element.
|
Optgroup |
DTO for an HTML <optgroup>
element.
|
Option |
DTO for an HTML <option>
element.
|
Output |
DTO for an HTML <output>
element.
|
P |
DTO for an HTML <p>
element.
|
Param |
DTO for an HTML <param>
element.
|
Pre |
DTO for an HTML <pre>
element.
|
Progress |
DTO for an HTML <progress>
element.
|
Q |
DTO for an HTML <q>
element.
|
Rb |
DTO for an HTML <rb>
element.
|
Rp |
DTO for an HTML <rp>
element.
|
Rt |
DTO for an HTML <rt>
element.
|
Rtc |
DTO for an HTML <rtc>
element.
|
Ruby |
DTO for an HTML <ruby>
element.
|
S |
DTO for an HTML <s>
element.
|
Samp |
DTO for an HTML <samp>
element.
|
Script |
DTO for an HTML <script>
element.
|
Section |
DTO for an HTML <section>
element.
|
Select |
DTO for an HTML <select>
element.
|
Small |
DTO for an HTML <small>
element.
|
Source |
DTO for an HTML <source>
element.
|
Span |
DTO for an HTML <span>
element.
|
Strong |
DTO for an HTML <strong>
element.
|
Style |
DTO for an HTML <style>
element.
|
Sub |
DTO for an HTML <sub>
element.
|
Sup |
DTO for an HTML <sup>
element.
|
Table |
DTO for an HTML <table>
element.
|
Tbody |
DTO for an HTML <tbody>
element.
|
Td |
DTO for an HTML <td>
element.
|
Template |
DTO for an HTML <template>
element.
|
Textarea |
DTO for an HTML <textarea>
element.
|
Tfoot |
DTO for an HTML <tfoot>
element.
|
Th |
DTO for an HTML <th>
element.
|
Thead |
DTO for an HTML <thead>
element.
|
Time |
DTO for an HTML <time>
element.
|
Title |
DTO for an HTML <title>
element.
|
Tr |
DTO for an HTML <tr>
element.
|
Track |
DTO for an HTML <track>
element.
|
U |
DTO for an HTML <u>
element.
|
Ul |
DTO for an HTML <ul>
element.
|
Var |
DTO for an HTML <var>
element.
|
Video |
DTO for an HTML <video>
element.
|
Wbr |
DTO for an HTML <wbr>
element.
|
HTML5 Data Transfer Objects
Juneau supports generation and consumption of HTML5 documents and fragments through the use of DTOs (Data
Transfer Objects).
It uses existing support for serializing and parsing POJOs to and from HTML to define these HTML objects.
The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML serializers, or to other languages such as JSON using the JSON serializers.
The HtmlBuilder
class is a utility class with predefined static methods
that allow you to easily construct DTO instances in a minimal amount of code.
The following examples show how to create HTML fragments:
Java code | HTML |
---|---|
|
|
|
|
|
|
|
Use the HtmlParser
to convert HTML5 documents back into their original POJOs:
HTML5 objects can also be constructed from the other media types using the appropriate parsers.
If you're finding yourself reusing the same HTML5 DTO objects over and over that only differ slightly, you may want to consider using HTML5 templates. Broadly speaking, a template is simply a bean that gets swapped out with another more complex bean during serialization. Juneau doesn't have a built-in concept of a "template", but rather has features that allow them to be defined using existing swap support.
The following example shows how an HTML5 form template object can be created that gets serialized as a
populated HTML5 Form
bean.
It takes advantage of the special swap(BeanSession)
method that serializers will use to
convert the object to a serialized form before serialization.
The return type of this method can be any serializable type.
In this case, we are defining a template for a reusable HTML form with two simple fields.
This gets serialized as an HTML form.
When serialized using the HTML or XML serializer, it produces the following:
Support for parsing back into the template class can be accomplished by adding an unswap method or constructor.
Refer to Swap methods for information about defining swap methods on classes.
*** fín ***
Copyright © 2018 Apache. All rights reserved.