Interface Headers

  • All Known Implementing Classes:
    HeadersImpl

    public interface Headers
    WComponents can use this interface to communicate "global" or "shared" items to the server. Examples are lines in the html/head element. It also allows for extra attributes on the html element itself.

    It is important to note that "headlines" must be added in the preparePaint phase. Headlines adding in serviceRequest will be lost because the headers are reset at the start of preparePaint. Adding headlines in the paint phase is too late as the headers have already been written. Note also that it would be possible to make the adding of headlines work for the paint phase, but at the expense of requiring the entire body of the page to be cached.

    Since:
    1.0.0
    Author:
    James Gifford, Martin Shevchenko
    • Method Detail

      • reset

        void reset()
        Called by the servlet between service requests.
      • addHeadLine

        void addHeadLine​(String aLine)
        Records a "shared" line for inclusion in the output.
        Parameters:
        aLine - the line to add.
      • addHeadLine

        void addHeadLine​(String type,
                         String aLine)
        Records a "shared" line (of a specified type) for inclusion in the output.
        Parameters:
        type - the type of line to add.
        aLine - the line to add.
      • addUniqueHeadLine

        void addUniqueHeadLine​(String aLine)
        Records a line for inclusion in the html/head, if it has not already been included.
        Parameters:
        aLine - the line to add.
      • addUniqueHeadLine

        void addUniqueHeadLine​(String type,
                               String aLine)
        Records a "shared" line (of a specified type) for inclusion in the output, if it has not already been included.

        An example of where this is useful is for adding shared JavaScript code.

        Parameters:
        type - the type of line to add.
        aLine - the line to add.
      • getHeadLines

        List getHeadLines()
        Returns:
        the "un-typed" head lines.
      • getHeadLines

        List getHeadLines​(String type)
        Get the head lines, of a specified type.
        Parameters:
        type - the type of headlines to return.
        Returns:
        the head lines, of a specified type
      • getContentType

        String getContentType()
        Get the content type (usually text/html).
        Returns:
        the content mime type.
      • setContentType

        void setContentType​(String type)
        Set the content type (usually text/html).
        Parameters:
        type - The content type to set on the response.