Package net.solarnetwork.web.support
Class AbstractView
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
- 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
- Direct Known Subclasses:
JSONView,SimpleCsvView,SimpleXmlView
public abstract class AbstractView
extends org.springframework.web.servlet.view.AbstractView
Extension of
AbstractView that
preserves model attribute ordering and supports serializing model properties
with a PropertySerializerRegistrar.- Version:
- 1.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]The default value for thejavaBeanIgnorePropertiesproperty.static final Class<?>[]The default value for thejavaBeanTreatAsStringValuesproperty.Fields 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 a set of JavaBean properties to ignore for all JavaBeans.Get the classes to treat as Strings for all JavaBeans.Get a set of class types to ignore from the model, and never output in the response.net.solarnetwork.codec.PropertySerializerRegistrarGet an optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values.protected StringGet the configured character encoding to use for the response.voidrender(Map<String, ?> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) This method performs the same functions asrender(Map, HttpServletRequest, HttpServletResponse)except that it uses a LinkedHashMap to preserve model order rather than a HashMap.voidsetJavaBeanIgnoreProperties(Set<String> javaBeanIgnoreProperties) Set a set of JavaBean properties to ignore for all JavaBeans.voidsetJavaBeanTreatAsStringValues(Set<Class<?>> javaBeanTreatAsStringValues) Set the classes to treat as Strings for all JavaBeans.voidsetModelObjectIgnoreTypes(Set<Class<?>> modelObjectIgnoreTypes) Set a set of class types to ignore from the model, and never output in the response.voidsetPropertySerializerRegistrar(net.solarnetwork.codec.PropertySerializerRegistrar propertySerializerRegistrar) Set an optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values.Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, renderMergedOutputModel, 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_JAVA_BEAN_IGNORE_PROPERTIES
The default value for thejavaBeanIgnorePropertiesproperty. -
DEFAULT_JAVA_BEAN_STRING_VALUES
The default value for thejavaBeanTreatAsStringValuesproperty.
-
-
Constructor Details
-
AbstractView
public AbstractView()
-
-
Method Details
-
render
public void render(Map<String, ?> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws ExceptionThis method performs the same functions asrender(Map, HttpServletRequest, HttpServletResponse)except that it uses a LinkedHashMap to preserve model order rather than a HashMap.- Specified by:
renderin interfaceorg.springframework.web.servlet.View- Overrides:
renderin classorg.springframework.web.servlet.view.AbstractView- Throws:
Exception
-
getResponseCharacterEncoding
Get the configured character encoding to use for the response.This method will extract the character encoding specified in
AbstractView.getContentType(), or default toUTF-8if none available.- Returns:
- character encoding name
-
getPropertySerializerRegistrar
public net.solarnetwork.codec.PropertySerializerRegistrar getPropertySerializerRegistrar()Get an optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values.- Returns:
- the registrar
-
setPropertySerializerRegistrar
public void setPropertySerializerRegistrar(net.solarnetwork.codec.PropertySerializerRegistrar propertySerializerRegistrar) Set an optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values.This can be useful for formatting Date objects into strings, for example.
- Parameters:
propertySerializerRegistrar- the registrar to use
-
getModelObjectIgnoreTypes
Get a set of class types to ignore from the model, and never output in the response.- Returns:
- the class set to use; defaults to an empty set
-
setModelObjectIgnoreTypes
Set a set of class types to ignore from the model, and never output in the response.- Parameters:
modelObjectIgnoreTypes- the class set to use
-
getJavaBeanIgnoreProperties
Get a set of JavaBean properties to ignore for all JavaBeans.- Returns:
- the properties to ignore; Defaults to
DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES.
-
setJavaBeanIgnoreProperties
Set a set of JavaBean properties to ignore for all JavaBeans.This is useful for omitting things like
classwhich is not usually desired.- Parameters:
javaBeanIgnoreProperties- the properties to ignore
-
getJavaBeanTreatAsStringValues
Get the classes to treat as Strings for all JavaBeans.- Returns:
- the class set; defaults to
DEFAULT_JAVA_BEAN_STRING_VALUES
-
setJavaBeanTreatAsStringValues
Set the classes to treat as Strings for all JavaBeans.This is useful for omitting object values such as Class objects, which is not usually desired.
- Parameters:
javaBeanTreatAsStringValues- the class set to use
-