Class VelocityPage

java.lang.Object
com.groiss.gui.VelocityPage
All Implemented Interfaces:
Page, StreamablePage

public class VelocityPage extends Object implements StreamablePage
Page implementation which can handle Velocity-templates
following objects may be used in the context by default and may not be used in set(String, Object)
See Also:
  • Constructor Details

    • VelocityPage

      public VelocityPage()
      if you use this constructor, you have to call setTemplate(String)
    • VelocityPage

      public VelocityPage(String resource)
      loads the given template. the Resource to use will be determined automatically
      Parameters:
      resource - the velocity template
  • Method Details

    • set

      public void set(String name, Object obj)
      adds the given object to the VelocityContext
      Parameters:
      name - variable name
      obj - object
    • show

      public String show()
      Description copied from interface: Page
      Called from the Dispatcher. Returns a String representation suitable for viewing in the browser (HTML, XHTML, plain text, etc.)
      Specified by:
      show in interface Page
    • output

      public void output(Writer w)
      Specified by:
      output in interface StreamablePage
    • getContentType

      public String getContentType()
      Description copied from interface: Page
      Returns the content type of the page, for example "text/html".
      Specified by:
      getContentType in interface Page
      Returns:
      the contents mime type as String
    • setTemplate

      public void setTemplate(String template)
      set the velocity-template
      Parameters:
      template - a string containing velocity-syntax
    • setContentType

      public void setContentType(String contentType)
      set the contenttype
      Parameters:
      contentType - the contenttype
    • getHeaders

      public List<Pair<String,Object>> getHeaders()
      Description copied from interface: Page
      Returns the list of http-response-headers to be set on the HttpServletResponse
      Specified by:
      getHeaders in interface Page
      Returns:
      the http-headers (the value may be one of String, Date or Integer
    • addHeader

      public void addHeader(String header, String value)
      Set a header field in the response before writing the page. Please note that HttpServletResponse.setHeader(String, String) will be used to set to the new value.
      Parameters:
      header - the name of the header
      value - the header value
    • addHeader

      public void addHeader(String header, Date value)
      Set a header field in the response before writing the page. Please note that HttpServletResponse.setDateHeader(String,long) will be used to set to the new value.
      Parameters:
      header - the name of the header
      value - the header value
    • addHeader

      public void addHeader(String header, int value)
      Set a header field in the response before writing the page. Please note that HttpServletResponse.setIntHeader(String,int) will be used to set to the new value.
      Parameters:
      header - the name of the header
      value - the header value