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

public class SimpleXmlView extends AbstractView
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 Details

    • DEFAULT_XML_CONTENT_TYPE

      public static final String DEFAULT_XML_CONTENT_TYPE
      Default content type.
      See Also:
    • DEFAULT_ROOT_ELEMENT_NAME

      public static final String DEFAULT_ROOT_ELEMENT_NAME
      The rootElementName property 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:
      renderMergedOutputModel in class org.springframework.web.servlet.view.AbstractView
      Throws:
      Exception
    • getRootElementName

      public String getRootElementName()
      Get the root XML element name to use.
      Returns:
      the root name; defaults to DEFAULT_ROOT_ELEMENT_NAME
    • setRootElementName

      public void setRootElementName(String rootElementName)
      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 TimeZone from the model for rendered dates, false to use UTC; 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 TimeZone is found as a model value, it will be used to render dates to string values. Otherwise UTC will be used.

      Parameters:
      useModelTimeZoneForDates - the setting to use
    • getModelKey

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

      public void setModelKey(String modelKey)
      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

      public ViewResponseAugmentor getRootElementAugmentor()
      Get the root element response augementor.
      Returns:
      the augmentor
    • setRootElementAugmentor

      public void setRootElementAugmentor(ViewResponseAugmentor rootElementAugmentor)
      Set the root element response augmentor.
      Parameters:
      rootElementAugmentor - the augmentor to set
    • getClassNamesAllowedForNesting

      public Set<String> getClassNamesAllowedForNesting()
      Get the class names allowed for nesting.
      Returns:
      the class names
    • setClassNamesAllowedForNesting

      public void setClassNamesAllowedForNesting(Set<String> classNamesAllowedForNesting)
      Set the class names allowed for nesting.
      Parameters:
      classNamesAllowedForNesting - the class names