Class HTMLPage

java.lang.Object
com.groiss.gui.HTMLPage
All Implemented Interfaces:
Page, Serializable
Direct Known Subclasses:
ActionPage, HTMLTree

public class HTMLPage extends Object implements Page, Serializable
An object representing an HTML page.
See Also:
  • Field Details

    • page

      protected String page
    • contentType

      protected String contentType
  • Constructor Details

    • HTMLPage

      public HTMLPage()
      Empty constructor, use setPage to fill the content.
    • HTMLPage

      public HTMLPage(String resource)
      Creates a HTMLPage with a content loaded from a file in classpath. The required resource bundle will be determined automatically.
    • HTMLPage

      public HTMLPage(String resource, Resource res)
      Creates a HTMLPage with a content loaded from a file in classpath.
  • Method Details

    • setPage

      public HTMLPage setPage(String s)
      Set the content of the page.
      Parameters:
      s - the content of the page
    • substitute

      public void substitute(String field, String value)
      Substitutes the field named by the first argument with the second argument.
      Parameters:
      field - the place-holder
      value - the value to be inserted
    • substEncoded

      public void substEncoded(String field, String value)
      Substitutes the field named by the first argument with the second argument. The value will be html-encoded.
      Parameters:
      field - the place-holder
      value - the value to be inserted
    • substitute

      public void substitute(String field, long value)
      Substitutes the field named by the first argument with the second argument.
      Parameters:
      field - the place-holder
      value - the value to be inserted
    • substitute

      public void substitute(String field, Object value)
      Substitutes the field named by the first argument with the second argument.
      Parameters:
      field - the place-holder
      value - the value to be inserted, toString is called on the object.
    • show

      public String show()
      This method returns the page contents.
      Specified by:
      show in interface Page
    • getContentType

      public String getContentType()
      This method returns the content type. If not set, the value "text/html" is returned.
      Specified by:
      getContentType in interface Page
      Returns:
      the content type of the page.
    • setContentType

      public void setContentType(String type)
      Set the content type.
      Parameters:
      type - the content type, for example "text/plain"
    • setMask

      @Deprecated public void setMask(String s)
      Deprecated.
      Set the mask template of the page. This method does the same as setPage() and is provided for compatibility.
      Parameters:
      s - the template of the page
    • 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