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

    Fields
    Modifier and Type
    Field
    Description
    static final String[]
    The default value for the javaBeanIgnoreProperties property.
    static final Class<?>[]
    The default value for the javaBeanTreatAsStringValues property.

    Fields inherited from class org.springframework.web.servlet.view.AbstractView

    DEFAULT_CONTENT_TYPE

    Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

    logger

    Fields inherited from interface org.springframework.web.servlet.View

    PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Get 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.PropertySerializerRegistrar
    Get an optional registrar of PropertySerializer instances that can be used to serialize specific objects into String values.
    protected String
    Get the configured character encoding to use for the response.
    void
    render(Map<String,?> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    This method performs the same functions as render(Map, HttpServletRequest, HttpServletResponse) except that it uses a LinkedHashMap to preserve model order rather than a HashMap.
    void
    setJavaBeanIgnoreProperties(Set<String> javaBeanIgnoreProperties)
    Set a set of JavaBean properties to ignore for all JavaBeans.
    void
    setJavaBeanTreatAsStringValues(Set<Class<?>> javaBeanTreatAsStringValues)
    Set the classes to treat as Strings for all JavaBeans.
    void
    setModelObjectIgnoreTypes(Set<Class<?>> modelObjectIgnoreTypes)
    Set a set of class types to ignore from the model, and never output in the response.
    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.

    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, writeToResponse

    Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

    getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext

    Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

    getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES

      public static final String[] DEFAULT_JAVA_BEAN_IGNORE_PROPERTIES
      The default value for the javaBeanIgnoreProperties property.
    • DEFAULT_JAVA_BEAN_STRING_VALUES

      public static final Class<?>[] DEFAULT_JAVA_BEAN_STRING_VALUES
      The default value for the javaBeanTreatAsStringValues property.
  • 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 Exception
      This method performs the same functions as render(Map, HttpServletRequest, HttpServletResponse) except that it uses a LinkedHashMap to preserve model order rather than a HashMap.
      Specified by:
      render in interface org.springframework.web.servlet.View
      Overrides:
      render in class org.springframework.web.servlet.view.AbstractView
      Throws:
      Exception
    • getResponseCharacterEncoding

      protected String getResponseCharacterEncoding()
      Get the configured character encoding to use for the response.

      This method will extract the character encoding specified in AbstractView.getContentType(), or default to UTF-8 if 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

      public Set<Class<?>> 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

      public void setModelObjectIgnoreTypes(Set<Class<?>> modelObjectIgnoreTypes)
      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

      public Set<String> 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

      public void setJavaBeanIgnoreProperties(Set<String> javaBeanIgnoreProperties)
      Set a set of JavaBean properties to ignore for all JavaBeans.

      This is useful for omitting things like class which is not usually desired.

      Parameters:
      javaBeanIgnoreProperties - the properties to ignore
    • getJavaBeanTreatAsStringValues

      public Set<Class<?>> getJavaBeanTreatAsStringValues()
      Get the classes to treat as Strings for all JavaBeans.
      Returns:
      the class set; defaults to DEFAULT_JAVA_BEAN_STRING_VALUES
    • setJavaBeanTreatAsStringValues

      public void setJavaBeanTreatAsStringValues(Set<Class<?>> javaBeanTreatAsStringValues)
      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