Class SimpleCsvView

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.SimpleCsvView
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 SimpleCsvView extends AbstractView
Spring View for turning objects into CSV through JavaBean introspection.

The character encoding of the output must be specified in the AbstractView.setContentType(String) (e.g. text/csv;charset=UTF-8).

The configurable properties of this class are:

dataModelKey
If not null, then use this model key as the data object to render as CSV. Otherwise, export just the first available key's associated object. Defaults to DEFAULT_DATA_MODEL_KEY.
fieldOrderKey
If not null, then use this model key as an ordered Collection of exported field names, such that the CSV columns will be exported in the specified order. If not specified, then for Map objects the output order will be determined by the natural iteration order of the Map keys, and for JavaBean objects the bean properties will be exported in case-insensitive alphabetical order. Defaults to DEFAULT_FIELD_ORDER_KEY.
Version:
1.1
Author:
matt
  • Field Details

    • DEFAULT_CSV_CONTENT_TYPE

      public static final String DEFAULT_CSV_CONTENT_TYPE
      Default content type.
      See Also:
    • DEFAULT_DATA_MODEL_KEY

      public static final String DEFAULT_DATA_MODEL_KEY
      The default value for the dataModelKey property.
      See Also:
    • DEFAULT_FIELD_ORDER_KEY

      public static final String DEFAULT_FIELD_ORDER_KEY
      The default value for the fieldOrderKey property.
      See Also:
  • Constructor Details

    • SimpleCsvView

      public SimpleCsvView()
      Default 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
    • getDataModelKey

      public String getDataModelKey()
      Get the data model key.
      Returns:
      the key to set
    • setDataModelKey

      public void setDataModelKey(String dataModelKey)
      Set the data model key.
      Parameters:
      dataModelKey - the key to set
    • getFieldOrderKey

      public String getFieldOrderKey()
      Get the field order key.
      Returns:
      the key to set
    • setFieldOrderKey

      public void setFieldOrderKey(String fieldOrderKey)
      Set the field order key.
      Parameters:
      fieldOrderKey - the key to set