@ConfigurableContext public class HtmlDocSerializer extends HtmlStrippedDocSerializer
Produces
HtmlSerializer
, except wraps the response in <html>
,
<head>
, and <body>
tags so that it can be rendered in a browser.
Configurable properties are typically specified via
Note that shortcut annotations are also provided for these particular settings:
The
These variables are replaced at runtime based on the HTTP request locale.
Several built-in runtime variable types are defined, and the API can be extended to include user-defined variables.
HtmlSerializer.Sq, HtmlSerializer.SqReadable
XmlSerializer.Ns, XmlSerializer.NsSq, XmlSerializer.NsSqReadable
Serializer.Null
Modifier and Type | Field and Description |
---|---|
static HtmlDocSerializer |
DEFAULT
Default serializer, all default settings.
|
static String |
HTMLDOC_aside
Configuration property: Aside section contents.
|
static String |
HTMLDOC_asideFloat
Configuration property: Float aside section contents.
|
static String |
HTMLDOC_footer
Configuration property: Footer section contents.
|
static String |
HTMLDOC_head
Configuration property: Additional head section content.
|
static String |
HTMLDOC_header
Configuration property: Header section contents.
|
static String |
HTMLDOC_nav
Configuration property: Nav section contents.
|
static String |
HTMLDOC_navlinks
Configuration property: Page navigation links.
|
static String |
HTMLDOC_navlinks_add
Configuration property: Add to the
HTMLDOC_navlinks property. |
static String |
HTMLDOC_noResultsMessage
Configuration property: No-results message.
|
static String |
HTMLDOC_nowrap
Configuration property: Prevent word wrap on page.
|
static String |
HTMLDOC_script
Configuration property: Javascript code.
|
static String |
HTMLDOC_script_add
Configuration property: Add to the
HTMLDOC_script property. |
static String |
HTMLDOC_style
Configuration property: CSS style code.
|
static String |
HTMLDOC_style_add
Configuration property: Add to the
HTMLDOC_style property. |
static String |
HTMLDOC_stylesheet
Configuration property: Stylesheet import URLs.
|
static String |
HTMLDOC_stylesheet_add
Configuration property: Add to the
HTMLDOC_stylesheet property. |
static String |
HTMLDOC_template
Configuration property: HTML document template.
|
static String |
HTMLDOC_widgets
Configuration property: HTML Widgets.
|
DEFAULT_SQ, DEFAULT_SQ_READABLE, HTML_addBeanTypes, HTML_addKeyValueTableHeaders, HTML_detectLabelParameters, HTML_detectLinksInStrings, HTML_labelParameter, HTML_uriAnchorText
DEFAULT_JUNEAU_NAMESPACE, DEFAULT_NS, DEFAULT_NS_SQ, DEFAULT_NS_SQ_READABLE, DEFAULT_XS_NAMESPACE, XML_addBeanTypes, XML_addNamespaceUrisToRoot, XML_autoDetectNamespaces, XML_defaultNamespace, XML_enableNamespaces, XML_namespaces, XML_xsNamespace
WSERIALIZER_fileCharset, WSERIALIZER_maxIndent, WSERIALIZER_quoteChar, WSERIALIZER_streamCharset, WSERIALIZER_useWhitespace
SERIALIZER_addBeanTypes, SERIALIZER_addRootType, SERIALIZER_keepNullProperties, SERIALIZER_listener, SERIALIZER_sortCollections, SERIALIZER_sortMaps, SERIALIZER_trimEmptyCollections, SERIALIZER_trimEmptyMaps, SERIALIZER_trimNullProperties, SERIALIZER_trimStrings, SERIALIZER_uriContext, SERIALIZER_uriRelativity, SERIALIZER_uriResolution
BEANTRAVERSE_detectRecursions, BEANTRAVERSE_ignoreRecursions, BEANTRAVERSE_initialDepth, BEANTRAVERSE_maxDepth
BEAN_annotations, BEAN_beanClassVisibility, BEAN_beanConstructorVisibility, BEAN_beanDictionary, BEAN_beanDictionary_add, BEAN_beanDictionary_remove, BEAN_beanFieldVisibility, BEAN_beanFilters, BEAN_beanFilters_add, BEAN_beanFilters_remove, BEAN_beanMapPutReturnsOldValue, BEAN_beanMethodVisibility, BEAN_beansRequireDefaultConstructor, BEAN_beansRequireSerializable, BEAN_beansRequireSettersForGetters, BEAN_beansRequireSomeProperties, BEAN_bpi, BEAN_bpro, BEAN_bpwo, BEAN_bpx, BEAN_examples, BEAN_excludeProperties, BEAN_fluentSetters, BEAN_ignoreInvocationExceptionsOnGetters, BEAN_ignoreInvocationExceptionsOnSetters, BEAN_ignorePropertiesWithoutSetters, BEAN_ignoreTransientFields, BEAN_ignoreUnknownBeanProperties, BEAN_ignoreUnknownNullBeanProperties, BEAN_implClasses, BEAN_includeProperties, BEAN_notBeanClasses, BEAN_notBeanClasses_add, BEAN_notBeanClasses_remove, BEAN_notBeanPackages, BEAN_notBeanPackages_add, BEAN_notBeanPackages_remove, BEAN_pojoSwaps, BEAN_pojoSwaps_add, BEAN_pojoSwaps_remove, BEAN_propertyNamer, BEAN_sortProperties, BEAN_swaps, BEAN_swaps_add, BEAN_swaps_remove, BEAN_typePropertyName, BEAN_useEnumNames, BEAN_useInterfaceProxies, BEAN_useJavaBeanIntrospector, DEFAULT_SORTED
CONTEXT_debug, CONTEXT_locale, CONTEXT_mediaType, CONTEXT_timeZone
Constructor and Description |
---|
HtmlDocSerializer(PropertyStore ps)
Constructor.
|
HtmlDocSerializer(PropertyStore ps,
String produces,
String accept)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
HtmlDocSerializerBuilder |
builder()
Creates a builder from this context object.
|
static HtmlDocSerializerBuilder |
create()
Instantiates a new clean-slate
HtmlDocSerializerBuilder object. |
HtmlDocSerializerSession |
createSession()
Create a new bean session based on the properties defined on this context.
|
HtmlDocSerializerSession |
createSession(SerializerSessionArgs args)
Create the session object used for actual serialization of objects.
|
protected String[] |
getAside()
Aside section contents.
|
protected AsideFloat |
getAsideFloat()
Float side section contents.
|
protected String[] |
getFooter()
Footer section contents.
|
protected String[] |
getHead()
Additional head section content.
|
protected String[] |
getHeader()
Header section contents.
|
protected String[] |
getNav()
Nav section contents.
|
protected String[] |
getNavlinks()
Page navigation links.
|
protected String |
getNoResultsMessage()
No-results message.
|
HtmlSerializer |
getSchemaSerializer()
Returns the schema serializer based on the settings of this serializer.
|
protected String[] |
getScript()
Javascript code.
|
protected String[] |
getStyle()
CSS style code.
|
protected String[] |
getStylesheet()
Stylesheet import URLs.
|
protected HtmlDocTemplate |
getTemplate()
HTML document template.
|
protected Map<String,HtmlWidget> |
getWidgets()
HTML widgets.
|
protected boolean |
isNowrap()
Prevent word wrap on page.
|
OMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
getHtmlBeanPropertyMeta, getHtmlClassMeta, getLabelParameter, getUriAnchorText, isAddBeanTypes, isAddKeyValueTableHeaders, isDetectLabelParameters, isDetectLinksInStrings
getDefaultNamespace, getNamespaces, getXmlBeanMeta, getXmlBeanPropertyMeta, getXmlClassMeta, getXsNamespace, isAddNamespaceUrlsToRoot, isAutoDetectNamespaces, isEnableNamespaces
getFileCharset, getMaxIndent, getQuoteChar, getStreamCharset, isUseWhitespace, isWriterSerializer, println, serialize, toString, toStringObject
createDefaultSessionArgs, getAcceptMediaTypes, getListener, getMediaTypeRanges, getPrimaryMediaType, getResponseContentType, getUriContext, getUriRelativity, getUriResolution, isAddRootType, isKeepNullProperties, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, serialize, serializeToString
createSession, getInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursions
_class, createBeanSession, createBeanSession, createDefaultBeanSessionArgs, createSession, dumpCacheStats, getAnnotations, getAnnotations, getAnnotations, getAnnotations, getAnnotations, getAnnotations, getAnnotations, getAnnotations, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanToStringSerializer, getBeanTypePropertyName, getBpi, getBpi, getBpro, getBpro, getBpwo, getBpwo, getBpx, getBpx, getClassMeta, getClassMeta, getClassMetaForObject, getDeclaredAnnotations, getDeclaredAnnotations, getExamples, getImplClassConstructor, getImplClasses, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastAnnotation, getLastDeclaredAnnotation, getLastDeclaredAnnotation, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPropertyNamer, getSwaps, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasSameCache, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreTransientFields, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isNotABean, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, object, resolveClassMeta, string
equals, getArrayProperty, getArrayProperty, getBooleanProperty, getCdlProperty, getClassArrayProperty, getClassArrayProperty, getClassArrayProperty, getClassListProperty, getClassListProperty, getClassMapProperty, getClassMapProperty, getClassProperty, getClassSetProperty, getClassSetProperty, getDefaultLocale, getDefaultMediaType, getDefaultTimeZone, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceProperty, getInstanceProperty, getInstanceProperty, getIntegerProperty, getListProperty, getListProperty, getLongProperty, getMapProperty, getProperty, getProperty, getPropertyKeys, getPropertyStore, getSetProperty, getSetProperty, getStringProperty, getStringPropertyWithNone, hashCode, identityCode, isDebug, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAnnotations, getAnnotations, getAnnotations, getAnnotations, getDeclaredAnnotations
public static final String HTMLDOC_aside
HTMLDOC_aside
Allows you to specify the contents of the aside section on the HTML page. The aside section floats on the right of the page for providing content supporting the serialized content of the page.
By default, the aside section is empty.
public static final String HTMLDOC_asideFloat
HTMLDOC_asideFloat
AsideFloat
AsideFloat.DEFAULT
Allows you to position the aside contents of the page around the main contents.
By default, the aside section is floated to the right.
public static final String HTMLDOC_footer
HTMLDOC_footer
Allows you to specify the contents of the footer section on the HTML page.
By default, the footer section is empty.
public static final String HTMLDOC_head
HTMLDOC_head
Adds the specified HTML content to the head section of the page.
A shortcut on
public static final String HTMLDOC_header
HTMLDOC_header
Allows you to override the contents of the header section on the HTML page. The header section normally contains the title and description at the top of the page.
public static final String HTMLDOC_nav
HTMLDOC_nav
Allows you to override the contents of the nav section on the HTML page. The nav section normally contains the page links at the top of the page.
When this property is specified, the HTMLDOC_navlinks
property is ignored.
public static final String HTMLDOC_navlinks
HTMLDOC_navlinks
Adds a list of hyperlinks immediately under the title and description but above the content of the page.
This can be used to provide convenient hyperlinks when viewing the REST interface from a browser.
The value is an array of strings with two possible values:
Relative URLs are considered relative to the servlet path.
For example, if the servlet path is UriResolver
such as
The
A shortcut on
public static final String HTMLDOC_navlinks_add
HTMLDOC_navlinks
property.public static final String HTMLDOC_noResultsMessage
HTMLDOC_noResultsMessage
Allows you to specify the string message used when trying to serialize an empty array or empty list.
A value of
public static final String HTMLDOC_nowrap
HTMLDOC_nowrap
Adds
public static final String HTMLDOC_script
HTMLDOC_script
Adds the specified Javascript code to the HTML page.
A shortcut on
public static final String HTMLDOC_script_add
HTMLDOC_script
property.public static final String HTMLDOC_style
HTMLDOC_style
Adds the specified CSS instructions to the HTML page.
A shortcut on
public static final String HTMLDOC_style_add
HTMLDOC_style
property.public static final String HTMLDOC_stylesheet
HTMLDOC_stylesheet
Adds a link to the specified stylesheet URL.
Note that this stylesheet is controlled by the
annotation.
public static final String HTMLDOC_stylesheet_add
HTMLDOC_stylesheet
property.public static final String HTMLDOC_template
HTMLDOC_template
Class<HtmlDocTemplate
>
BasicHtmlDocTemplate
Specifies the template to use for serializing the page.
By default, the BasicHtmlDocTemplate
class is used to construct the contents of the HTML page, but
can be overridden with your own custom implementation class.
public static final String HTMLDOC_widgets
HTMLDOC_widgets
HtmlWidget
|Class<HtmlWidget
>>
Defines widgets that can be used in conjunction with string variables of the form
HtmlWidget.getHtml(VarResolverSession)
.
HtmlWidget.getScript(VarResolverSession)
.
HtmlWidget.getStyle(VarResolverSession)
.
The following examples shows how to associate a widget with a REST method and then have it rendered in the links and aside section of the page:
public static final HtmlDocSerializer DEFAULT
public HtmlDocSerializer(PropertyStore ps)
ps
- The property store containing all the settings for this object.public HtmlDocSerializer(PropertyStore ps, String produces, String accept)
ps
- The property store containing all the settings for this object.produces
- The media type that this serializer produces.accept
- The accept media types that the serializer can handle.
Can contain meta-characters per the
If empty, then assumes the only media type supported is
For example, if this serializer produces
The accept value can also contain q-values.
public HtmlDocSerializerBuilder builder()
Context
Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
builder
in class HtmlStrippedDocSerializer
public static HtmlDocSerializerBuilder create()
HtmlDocSerializerBuilder
object.
This is equivalent to simply calling
.
Note that this method creates a builder initialized to all default settings, whereas builder()
copies
the settings of the object called on.
HtmlDocSerializerBuilder
object.public HtmlDocSerializerSession createSession()
BeanContext
Use this method for creating sessions if you don't need to override any properties or locale/timezone currently set on this context.
createSession
in class HtmlStrippedDocSerializer
public HtmlDocSerializerSession createSession(SerializerSessionArgs args)
Serializer
createSession
in class HtmlStrippedDocSerializer
args
- Runtime arguments.
These specify session-level information such as locale and URI context.
It also include session-level properties that override the properties defined on the bean and serializer
contexts.public HtmlSerializer getSchemaSerializer()
XmlSerializer
getSchemaSerializer
in class HtmlSerializer
protected final String[] getAside()
HTMLDOC_aside
protected final AsideFloat getAsideFloat()
HTMLDOC_asideFloat
protected final String[] getFooter()
HTMLDOC_footer
protected final String[] getHead()
HTMLDOC_head
protected final String[] getHeader()
HTMLDOC_header
protected final String[] getNav()
HTMLDOC_nav
protected final String[] getNavlinks()
HTMLDOC_navlinks
protected final String getNoResultsMessage()
HTMLDOC_noResultsMessage
protected final boolean isNowrap()
HTMLDOC_nowrap
protected final String[] getScript()
HTMLDOC_script
protected final String[] getStyle()
HTMLDOC_style
protected final String[] getStylesheet()
HTMLDOC_stylesheet
protected final HtmlDocTemplate getTemplate()
HTMLDOC_template
protected final Map<String,HtmlWidget> getWidgets()
HTMLDOC_widgets
public OMap toMap()
Context
toMap
in class HtmlStrippedDocSerializer
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.