Package net.solarnetwork.web.support
Class SimpleXmlView
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
net.solarnetwork.web.support.AbstractView
net.solarnetwork.web.support.SimpleXmlView
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware,org.springframework.web.servlet.View
Spring
View for turning objects into
XML through JavaBean introspection.
The character encoding of the output must be specified in the
AbstractView.setContentType(String) (e.g. text/xml;charset=UTF-8).
- Version:
- 1.4
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTherootElementNameproperty default value.static final StringDefault content type.Fields inherited from class net.solarnetwork.web.support.AbstractView
DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES, DEFAULT_JAVA_BEAN_STRING_VALUESFields inherited from class org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPEFields inherited from class org.springframework.context.support.ApplicationObjectSupport
loggerFields inherited from interface org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the class names allowed for nesting.Get a specific model key to render into XML.Get the root element response augementor.Get the root XML element name to use.booleanGet the single-bean-as-root setting.booleanGet the model time zone settings.protected voidrenderMergedOutputModel(Map<String, Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidsetClassNamesAllowedForNesting(Set<String> classNamesAllowedForNesting) Set the class names allowed for nesting.voidsetModelKey(String modelKey) Set the model key to use as the object to render to XML.voidsetRootElementAugmentor(ViewResponseAugmentor rootElementAugmentor) Set the root element response augmentor.voidsetRootElementName(String rootElementName) A root XML element name to use for the view output.voidsetSingleBeanAsRoot(boolean singleBeanAsRoot) Toggle the single-bean-as-root setting.voidsetUseModelTimeZoneForDates(boolean useModelTimeZoneForDates) Toggle the use of a model-specific time zone for date values.Methods inherited from class net.solarnetwork.web.support.AbstractView
getJavaBeanIgnoreProperties, getJavaBeanTreatAsStringValues, getModelObjectIgnoreTypes, getPropertySerializerRegistrar, getResponseCharacterEncoding, render, setJavaBeanIgnoreProperties, setJavaBeanTreatAsStringValues, setModelObjectIgnoreTypes, setPropertySerializerRegistrarMethods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, toString, writeToResponseMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
-
Field Details
-
DEFAULT_XML_CONTENT_TYPE
Default content type.- See Also:
-
DEFAULT_ROOT_ELEMENT_NAME
TherootElementNameproperty default value.- See Also:
-
-
Constructor Details
-
SimpleXmlView
public SimpleXmlView()Constructor.
-
-
Method Details
-
renderMergedOutputModel
protected void renderMergedOutputModel(Map<String, Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception- Specified by:
renderMergedOutputModelin classorg.springframework.web.servlet.view.AbstractView- Throws:
Exception
-
getRootElementName
Get the root XML element name to use.- Returns:
- the root name; defaults to
DEFAULT_ROOT_ELEMENT_NAME
-
setRootElementName
A root XML element name to use for the view output.See
setSingleBeanAsRoot(boolean)which can be used to render a single view object as the root element name instead of this value.- Parameters:
rootElementName- the root element name to use
-
isSingleBeanAsRoot
public boolean isSingleBeanAsRoot()Get the single-bean-as-root setting.- Returns:
- true to treat models with a single object as the root
element, otherwise
#getRootElementName()should be used; defaults to true
-
setSingleBeanAsRoot
public void setSingleBeanAsRoot(boolean singleBeanAsRoot) Toggle the single-bean-as-root setting.When true then if the model is a single object, it will be used as the output root element. Otherwise
getRootElementName()will be used as the root element.- Parameters:
singleBeanAsRoot- the single bean as root setting to use
-
isUseModelTimeZoneForDates
public boolean isUseModelTimeZoneForDates()Get the model time zone settings.- Returns:
- true to use a
TimeZonefrom the model for rendered dates, false to useUTC; defaults to true
-
setUseModelTimeZoneForDates
public void setUseModelTimeZoneForDates(boolean useModelTimeZoneForDates) Toggle the use of a model-specific time zone for date values.When true, if a
TimeZoneis found as a model value, it will be used to render dates to string values. OtherwiseUTCwill be used.- Parameters:
useModelTimeZoneForDates- the setting to use
-
getModelKey
Get a specific model key to render into XML.- Returns:
- the model key to use for the output XML, or null to use the entire model
-
setModelKey
Set the model key to use as the object to render to XML.- Parameters:
modelKey- the model key to use, or null to render the entire model
-
getRootElementAugmentor
Get the root element response augementor.- Returns:
- the augmentor
-
setRootElementAugmentor
Set the root element response augmentor.- Parameters:
rootElementAugmentor- the augmentor to set
-
getClassNamesAllowedForNesting
Get the class names allowed for nesting.- Returns:
- the class names
-
setClassNamesAllowedForNesting
Set the class names allowed for nesting.- Parameters:
classNamesAllowedForNesting- the class names
-