jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class Page

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byuk.co.weft.maybeupload.MaybeUploadServlet
              extended byuk.co.weft.htform.Servlet
                  extended byuk.co.weft.htform.WithExceptionHandlerServlet
                      extended byuk.co.weft.htform.Page
All Implemented Interfaces:
ResourceConsumer, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
CompositeStylesheetSample, Form

public abstract class Page
extends WithExceptionHandlerServlet

An HTML page, generated by a servlet. This class (and consequently all servlets which are subclasses of this class) know about the following configuration parameters, in addition to those handled by Servlet:

doctype
String: The SGML doctypt to declare for this page. Optional. Defaults to HTML 4 Transitional.
dynamic_foot_include
Boolean: whether or not the foot_include_url should be pulled at each service. May be used in conjunction with specialisation of getHeadIncludeURL, in which case the URL pulled may be computed from the context. Optional. Defaults to false. Since Jacquard 1.9.
dynamic_head_include
Boolean: whether or not the head_include_url should be pulled at each service. May be used in conjunction with specialisation of getHeadIncludeURL, in which case the URL pulled may be computed from the context. Optional. Defaults to false.
foot_include_url
URL: a URL pointing to an HTML fragment to be spliced in to the end of the BODY of the page - you must include a valid URL here. If you're using dynamic head includes and specialising getHeadIncludeURL() you may not actually use the URL you supply here but you must nevertheless supply a valid one. Optional. No default. Since Jacquard 1.9.
head_include_url
URL: a URL pointing to an HTML fragment to be spliced in to the start of the BODY of the page - you must include a valid URL here. If you're using dynamic head includes and specialising getHeadIncludeURL() you may not actually use the URL you supply here but you must nevertheless supply a valid one. Optional. No default.
image_url_base
URL (may be relative): the URL of a directory from which utility images can be fetched. Optional. Defaults to ../images/
print_stylesheet
URL (may be relative): The URL of the CSS stylesheet to use for media="print". Optional. No default.
stylesheet
URL (may be relative): The URL of the CSS stylesheet to be used to format this page. Optional.
title
String: The title of this page. Optional. No default.

Version:
$Revision: 1.47.4.4 $ This revision: $Author: simon $
Author:
Simon Brooke
See Also:
Servlet, Serialized Form

Field Summary
static java.lang.String DOCTYPECONFIGTOKEN
          a magic token on which we will seek the value of the document type declaration in the configuration
protected  java.lang.Boolean dynamicFootInclude
          whether the fragment should be refetched at each request (we really don't want to have to do this
protected  java.lang.Boolean dynamicHeadInclude
          whether the fragment should be refetched at each request (we really don't want to have to do this
protected  java.lang.String footInclude
          an HTML fragment to include at the beginning of the body of each page
protected  java.lang.String footIncludeURL
          the URL from which that fragment should be fetched
protected  java.lang.String headInclude
          an HTML fragment to include at the beginning of the body of each page
protected  java.lang.String headIncludeURL
          the URL from which that fragment should be fetched
protected  java.lang.String imageUrlBase
          the base URL for utility images I may need
protected  Layout layout
          My layout engine.
protected  java.lang.String printStylesheet
          The URL of my print stylsheet
static java.lang.String PRINTSTYLESHEETCONFIGTOKEN
          a magic token on which we will seek in the configuration for the URL of the stylesheet for media="print"
protected  java.lang.String stylesheet
          The URI of my stylesheet
static java.lang.String STYLESHEETCONFIGTOKEN
          a magic token on which we will seek in the configuration for the URL of the stylesheet for media="screen"
protected  java.lang.String title
          my title.
protected  java.lang.String titleMagicToken
          Deprecated. use TITLEMAGICTOKEN
static java.lang.String TITLEMAGICTOKEN
          a magic token to allow my title to be extracted from the context
 
Fields inherited from class uk.co.weft.htform.WithExceptionHandlerServlet
EXCEPTIONHANDLERCLASSCONFIGTOKEN
 
Fields inherited from class uk.co.weft.htform.Servlet
calendar, conf, contentType, CONTENTTYPECONFIGTOKEN, cookieDomain, cookiePath, COOKIESCONFIGTOKEN, cookieTTL, dbPassword, dbUrl, dbUsername, debug, DEBUGCONFIGTOKEN, driverName, embedded, here, identity, localeMagicToken, LOCALEMAGICTOKEN, outputStreamMagicToken, OUTPUTSTREAMMAGICTOKEN, parsePathInfo, PATHINFOMAGICTOKEN, ready, redirectMagicToken, REDIRECTMAGICTOKEN, requestMagicToken, REQUESTMAGICTOKEN, resourceBundleName, responseMagicToken, RESPONSEMAGICTOKEN, servletMagicToken, SERVLETMAGICTOKEN, sessionMagicToken, SESSIONMAGICTOKEN, USEHTTPSCONFIGTOKEN, zone
 
Fields inherited from class uk.co.weft.maybeupload.MaybeUploadServlet
allowOverwrite, maxUpload, saveUploadedFilesToDisk, silentlyRename, uploadDir, uploadDirPath, uploadDirURL
 
Fields inherited from interface uk.co.weft.htform.ResourceConsumer
RESOURCEBUNDLEMAGICTOKEN
 
Constructor Summary
Page()
           
 
Method Summary
protected abstract  void doBody(Context context)
          Specialise! Do not use! Output what is to appear on your page between (but not including) the BODY tags.
protected  void doFoot(Context context)
          Output standardised footer.
protected  void doFoot(Context context, java.lang.String message)
          output a footer onto my output stream, incorporating a supplied message.
protected  void doHead(Context context)
          Output an HTML HEAD section, up to but not including the closing /HEAD tag.
protected  void doHeadBodySep(Context context)
          Output the close of the head tag and the opening of the body tag.
protected  void generateContent(Context context)
          Generate the content of a normal page, by generating first the head, then the body tag, then the body content.
protected  java.lang.String getFootInclude(Context context)
          fetch the foot include (if any) for this context.
protected  java.net.URL getFootIncludeURL(java.lang.String dflt, Context context)
          If you're using dynamic foot includes, you probably want to specialise to generate a URL based on something in the context.
protected  java.net.URL getFootIncludeURL(java.net.URL dflt, Context context)
          If you're using dynamic foot includes, you probably want to specialise to generate a URL based on something in the context.
protected  java.lang.String getHeadInclude(Context context)
          fetch the head include (if any) for this context.
protected  java.net.URL getHeadIncludeURL(java.lang.String dflt, Context context)
          If you're using dynamic head includes, you probably want to specialise to generate a URL based on something in the context.
protected  java.net.URL getHeadIncludeURL(java.net.URL dflt, Context context)
          Deprecated. replaced with getHeadIncludeURL(String,Context) which is able to fix up relative URLs
 Layout getLayout(Context context)
          Return my layout engine for this context.
protected  java.lang.String getStylesheet(Context context)
          Deprecated. probably better to use getStylesheets(Context)
 java.util.Vector getStylesheets(Context context)
          get the URLs of multiple stylesheets to use in this context.
protected  boolean getTables()
          return the value of my tables iv
protected  java.lang.String getTitle()
          Deprecated. use getTitle( Context) in preference
protected  java.lang.String getTitle(Context context)
          construct and return a suitable title for this page in this context.
 void init(Context config)
          Initialisation: Set up my variables from my configuration.
protected  void outputRedirectBlock(Context context)
          Output a stub HTML page with a 'refresh' meta.
protected  java.lang.String readStringFromURL(java.net.URL source)
          read the value at this URL and return it as a string
 
Methods inherited from class uk.co.weft.htform.WithExceptionHandlerServlet
whinge, whinge, whinge
 
Methods inherited from class uk.co.weft.htform.Servlet
addCookie, addCookie, coerceCookiesToContext, coerceToContext, coerceToContext, coerceToContext, coerceToContext, coerceToUrl, createContext, doGet, doPost, fixupMagicValues, getCalendar, getContentType, getDebug, getLocale, getOutputStream, getResource, getResourceString, getServletInfo, grs, grs, handleAction, handleCookies, handleRedirect, init, makeReady, setCookieValues, storeOnSession
 
Methods inherited from class uk.co.weft.maybeupload.MaybeUploadServlet
doDelete, doHead, doOptions, doPut, doTrace, getUploadDir, getUploadURL, service
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TITLEMAGICTOKEN

public static final java.lang.String TITLEMAGICTOKEN
a magic token to allow my title to be extracted from the context

See Also:
Constant Field Values

STYLESHEETCONFIGTOKEN

public static final java.lang.String STYLESHEETCONFIGTOKEN
a magic token on which we will seek in the configuration for the URL of the stylesheet for media="screen"

See Also:
Constant Field Values

PRINTSTYLESHEETCONFIGTOKEN

public static final java.lang.String PRINTSTYLESHEETCONFIGTOKEN
a magic token on which we will seek in the configuration for the URL of the stylesheet for media="print"

See Also:
Constant Field Values

DOCTYPECONFIGTOKEN

public static final java.lang.String DOCTYPECONFIGTOKEN
a magic token on which we will seek the value of the document type declaration in the configuration

See Also:
Constant Field Values

dynamicFootInclude

protected java.lang.Boolean dynamicFootInclude
whether the fragment should be refetched at each request (we really don't want to have to do this

Since:
Jacquard 1.9

dynamicHeadInclude

protected java.lang.Boolean dynamicHeadInclude
whether the fragment should be refetched at each request (we really don't want to have to do this


footInclude

protected java.lang.String footInclude
an HTML fragment to include at the beginning of the body of each page

Since:
Jacquard 1.9

headInclude

protected java.lang.String headInclude
an HTML fragment to include at the beginning of the body of each page


imageUrlBase

protected java.lang.String imageUrlBase
the base URL for utility images I may need

Since:
Jacquard 1.10

title

protected java.lang.String title
my title.

See Also:
getTitle()

titleMagicToken

protected final java.lang.String titleMagicToken
Deprecated. use TITLEMAGICTOKEN

a magic token to allow my title to be extracted from the context

See Also:
Constant Field Values

layout

protected Layout layout
My layout engine.

See Also:
Layout

footIncludeURL

protected java.lang.String footIncludeURL
the URL from which that fragment should be fetched

Since:
Jacquard 1.9

headIncludeURL

protected java.lang.String headIncludeURL
the URL from which that fragment should be fetched


printStylesheet

protected java.lang.String printStylesheet
The URL of my print stylsheet


stylesheet

protected java.lang.String stylesheet
The URI of my stylesheet

Constructor Detail

Page

public Page()
Method Detail

getLayout

public Layout getLayout(Context context)
                 throws javax.servlet.ServletException
Return my layout engine for this context. Currently only used by Form and it's subclasses, but defined here because later is may not be.

Parameters:
context - is passed because later we may want to use different layout engines for different browsers (or, conceivably, different levels of security clearance or whatever)
Throws:
javax.servlet.ServletException
See Also:
Layout

getStylesheets

public java.util.Vector getStylesheets(Context context)
                                throws java.lang.Exception
get the URLs of multiple stylesheets to use in this context. Default just returns a vector wrapped around the output of getStylesheet(Context).

Parameters:
context - the context of this service
Returns:
a vector all of whose members are URLs or string representations of URLs, all of which point to CSS stylesheets. Must return a vector (even if empty) rather than null.
Throws:
java.lang.Exception
Since:
Jacquard 1.9

init

public void init(Context config)
          throws InitialisationException
Initialisation: Set up my variables from my configuration.

Overrides:
init in class WithExceptionHandlerServlet
Throws:
InitialisationException

getFootInclude

protected java.lang.String getFootInclude(Context context)
fetch the foot include (if any) for this context. You probably don't want to specialise this; you probably want to specialise getFootIncludeURL.

Parameters:
context - the context for this service
Returns:
a string representing the HTML fragment to be spliced in
Since:
Jacquard 1.9

getFootIncludeURL

protected java.net.URL getFootIncludeURL(java.net.URL dflt,
                                         Context context)
                                  throws java.lang.Exception
If you're using dynamic foot includes, you probably want to specialise to generate a URL based on something in the context.

Parameters:
dflt - the default URL to return if you don't find anything interesting in the context
context - the context for this service.
Throws:
java.lang.Exception - not actually thrown, but things which specialise this may throw anything.
Since:
Jacquard 1.9

getFootIncludeURL

protected java.net.URL getFootIncludeURL(java.lang.String dflt,
                                         Context context)
                                  throws java.lang.Exception
If you're using dynamic foot includes, you probably want to specialise to generate a URL based on something in the context.

Parameters:
dflt - the default URL to return if you don't find anything interesting in the context
context - the context for this service.
Throws:
java.lang.Exception - not actually thrown, but things which specialise this may throw anything.
Since:
Jacquard 1.9

getHeadInclude

protected java.lang.String getHeadInclude(Context context)
fetch the head include (if any) for this context. You probably don't want to specialise this; you probably want to specialise getHeadIncludeURL.

Parameters:
context - the context for this service
Returns:
a string representing the HTML fragment to be spliced in

getHeadIncludeURL

protected java.net.URL getHeadIncludeURL(java.net.URL dflt,
                                         Context context)
                                  throws java.lang.Exception
Deprecated. replaced with getHeadIncludeURL(String,Context) which is able to fix up relative URLs

If you're using dynamic head includes, you probably want to specialise to generate a URL based on something in the context.

Parameters:
dflt - the default URL to return if you don't find anything interesting in the context
context - the context for this service.
Throws:
java.lang.Exception - not actually thrown, but things which specialise this may throw anything.

getHeadIncludeURL

protected java.net.URL getHeadIncludeURL(java.lang.String dflt,
                                         Context context)
                                  throws java.lang.Exception
If you're using dynamic head includes, you probably want to specialise to generate a URL based on something in the context.

Parameters:
dflt - the default URL to return if you don't find anything interesting in the context
context - the context for this service.
Throws:
java.lang.Exception - not actually thrown, but things which specialise this may throw anything.

getStylesheet

protected java.lang.String getStylesheet(Context context)
                                  throws java.lang.Exception
Deprecated. probably better to use getStylesheets(Context)

get the style sheet to use in this context; a hack, needs rethought in the light of separate layout engines. Default just returns the value of the stylesheet iv

Throws:
java.lang.Exception

getTables

protected boolean getTables()
return the value of my tables iv


getTitle

protected java.lang.String getTitle()
Deprecated. use getTitle( Context) in preference

construct and return a suitable title for this form.


getTitle

protected java.lang.String getTitle(Context context)
construct and return a suitable title for this page in this context.

Parameters:
context - the context for this service
Returns:
a suitable title string for this page for this service

doBody

protected abstract void doBody(Context context)
                        throws java.lang.Exception
Specialise! Do not use! Output what is to appear on your page between (but not including) the BODY tags.

Throws:
java.lang.Exception

doFoot

protected void doFoot(Context context)
               throws java.lang.Exception
Output standardised footer.

Throws:
java.lang.Exception

doFoot

protected void doFoot(Context context,
                      java.lang.String message)
               throws java.lang.Exception
output a footer onto my output stream, incorporating a supplied message.

Throws:
java.lang.Exception

doHead

protected void doHead(Context context)
               throws java.lang.Exception
Output an HTML HEAD section, up to but not including the closing /HEAD tag. The reason for not including it is to allow specialisations to start with super.doHead(), before emitting whatever head content they themselves need to emit.

Throws:
java.lang.Exception

doHeadBodySep

protected void doHeadBodySep(Context context)
                      throws java.lang.Exception
Output the close of the head tag and the opening of the body tag.

Throws:
java.lang.Exception

generateContent

protected void generateContent(Context context)
                        throws java.lang.Exception
Generate the content of a normal page, by generating first the head, then the body tag, then the body content. This is old code and the API is not very clean - I wouldn't do it this way now.

Specified by:
generateContent in class Servlet
Parameters:
context - the context for this service
Throws:
java.lang.Exception - actually does not throw any exception, but conforms to an API which may

outputRedirectBlock

protected void outputRedirectBlock(Context context)
                            throws java.io.IOException
Output a stub HTML page with a 'refresh' meta. Should be redundent, because only output it a type 302 response has already been sent, so should never be seen... but does no harm

Overrides:
outputRedirectBlock in class Servlet
Parameters:
context - the context for this service
Throws:
java.io.IOException - if output barfs.

readStringFromURL

protected java.lang.String readStringFromURL(java.net.URL source)
                                      throws java.io.IOException
read the value at this URL and return it as a string

Parameters:
source - where to read from
Returns:
a string representation of the data fetched from the URL
Throws:
java.io.IOException
Since:
Jacquard 1.9

jacquard 1.12.0 by The Web Engineering Factory and Toolworks