Enhydra 5.1 API

com.lutris.appserver.server.jolt.joltpo
Class JoltPage

java.lang.Object
  |
  +--com.lutris.appserver.server.jolt.joltpo.JoltPage
All Implemented Interfaces:
HttpPresentation

public abstract class JoltPage
extends java.lang.Object
implements HttpPresentation

Base class of a Jolt-HTML page. Each page extends this class. It is also passed to each of the page component objects as an argument.

Version:
$Revision: 1.1 $
Author:
Mark Diekhans

Field Summary
 Application application
          Application object that this presentation is associated with.
 JoltCallArgs callArgs
          On Jolt calls, contains the arguments specified in the <JOLT CALL> tag.
 JoltPageData data
          Table used to set Jolt fields, contains CGI args, etc.
 java.lang.Throwable exception
          If an exception/error occured, this field is set to the exception object.
protected static int HTML_ENCODING
          Use HTML encoding.
protected static int JAVASCRIPT_ENCODING
          Use JavaScript encoding.
protected static int NO_ENCODING
          Use no encoding.
protected  HttpPresentationComms presentationComms
           
protected  java.util.Hashtable queryTable
          CGI arguments, stored as a hash table.
 JoltRequest request
          Request object that contains the data from the HTTP request.
 JoltResponse response
          Response object used to set cookies and other headers.
 Session session
          Session object that this presentation is associated with.
 java.lang.String tagContents
          On Jolt calls, contains the body of the tag between <JOLT CALL> and </JOLT>.
 
Constructor Summary
JoltPage()
           
 
Method Summary
 void append(java.lang.String html)
          Append HTML to the current page.
 void append(java.lang.StringBuffer html)
          Append HTML to the current page.
protected  void appendFieldValue(java.lang.String field, int encoding, java.lang.String defaultValue)
          Function to append a field from keyword/value table.
 void appendln(java.lang.String html)
          Append HTML to the current page with carrage return.
 void appendln(java.lang.StringBuffer html)
          Append HTML to the current page with carrage return.
 void clear()
          Clears the internal buffer of HTML appended since the last flush() or since the beginning of the page.
protected  boolean fieldCompare(java.lang.String keyword, java.lang.String str)
          Determine if a specified field's value compares to a string.
protected  boolean fieldExists(java.lang.String keyword)
          Determine if a specified field is defined.
 void flush()
          Write all currently buffered HTML to the client.
protected  void parseCgiArgs()
          Parse CGI arguments into a keyword/value table and save in the page data object.
 void run(HttpPresentationComms comms)
          Abstract methods that run all code on the page and output the results to the HTTP client.
protected abstract  void runPage()
          Methods defined by the derived class that executes the contents of the page.
protected  void sourceFile(java.lang.String appFileName)
          Sources a file found by the class loader, appending it to the output buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML_ENCODING

protected static final int HTML_ENCODING
Use HTML encoding.

See Also:
Constant Field Values

JAVASCRIPT_ENCODING

protected static final int JAVASCRIPT_ENCODING
Use JavaScript encoding.

See Also:
Constant Field Values

NO_ENCODING

protected static final int NO_ENCODING
Use no encoding.

See Also:
Constant Field Values

request

public JoltRequest request
Request object that contains the data from the HTTP request.


response

public JoltResponse response
Response object used to set cookies and other headers.


data

public JoltPageData data
Table used to set Jolt fields, contains CGI args, etc.


callArgs

public JoltCallArgs callArgs
On Jolt calls, contains the arguments specified in the <JOLT CALL> tag.


tagContents

public java.lang.String tagContents
On Jolt calls, contains the body of the tag between <JOLT CALL> and </JOLT>.


application

public Application application
Application object that this presentation is associated with. If null, no application is associated.


session

public Session session
Session object that this presentation is associated with. If null, no session has been associated by the application.


exception

public java.lang.Throwable exception
If an exception/error occured, this field is set to the exception object. This is only set for and used by `ErrorHandler' presentations.


queryTable

protected java.util.Hashtable queryTable
CGI arguments, stored as a hash table.


presentationComms

protected HttpPresentationComms presentationComms
Constructor Detail

JoltPage

public JoltPage()
Method Detail

append

public void append(java.lang.String html)
Append HTML to the current page.

Parameters:
html - string to append.

append

public void append(java.lang.StringBuffer html)
Append HTML to the current page.

Parameters:
html - string buffer to append.

appendln

public void appendln(java.lang.String html)
Append HTML to the current page with carrage return.

Parameters:
html - string to append.

appendln

public void appendln(java.lang.StringBuffer html)
Append HTML to the current page with carrage return.

Parameters:
html - string buffer to append.

fieldExists

protected boolean fieldExists(java.lang.String keyword)
                       throws HttpPresentationException
Determine if a specified field is defined.

Parameters:
keyword - Key of the object in the page data table to check.
Returns:
If the field exists in the page data table, true, if not false.
Throws:
HttpPresentationException - If keyword is invalid.

fieldCompare

protected boolean fieldCompare(java.lang.String keyword,
                               java.lang.String str)
                        throws HttpPresentationException
Determine if a specified field's value compares to a string.

Parameters:
keyword - Key of the object in the page data table.
str - String to compare
Returns:
If the field's string representation is is equal to str true is returned, if they are not equal or false if the strings are not equal or the field does not exist.
Throws:
HttpPresentationException - If keyword is invalid.

clear

public void clear()
Clears the internal buffer of HTML appended since the last flush() or since the beginning of the page. Note that it does not effect HTTP headers. It can be used effectively to replace the dynamically generated page with an HTML error.


flush

public void flush()
           throws HttpPresentationException
Write all currently buffered HTML to the client. This is normally not necessary, as the data is all written when the page run method completes. This is provide mainly to allow a stream of JavaScript to be written to the client while some long-running task is waiting to complete. The first time this function is called, any response cookies or headers that have been set are sent to the client. Attempts to set response cookies or headers after this function has been called will result in an error.

HttpPresentationException

appendFieldValue

protected void appendFieldValue(java.lang.String field,
                                int encoding,
                                java.lang.String defaultValue)
                         throws java.lang.Exception
Function to append a field from keyword/value table. If the value is a section (recursive key/value table), Then its formatted as HTML. In addition, if any object implements a toHtml() method then this is invoked to generate HTML output.

Parameters:
field - Name of field to append.
encoding - Type of encoding to use. One of HTML_ENCODING, JAVASCRIPT_ENCODING, or NO_ENCODING.
defaultValue - The default value to use, or null if no default.
Throws:
java.lang.Exception - JoltHTML page objects may throw any exception.

sourceFile

protected void sourceFile(java.lang.String appFileName)
                   throws java.io.IOException,
                          HttpPresentationException
Sources a file found by the class loader, appending it to the output buffer.

Parameters:
appFileName - The file to source. It may either be relative to the path of this presentation object, or absolute, which makes it relative to the application's presentationPrefix.
Throws:
java.io.IOException - If the file can not be found or opened or an I/O error occurs.
HttpPresentationException

parseCgiArgs

protected void parseCgiArgs()
                     throws java.lang.Exception
Parse CGI arguments into a keyword/value table and save in the page data object. In certain cases, this behavior might not be desirable, such as the argument names not being legal keywords. In this case, the Jolt object can override this method to do what ever it wants.

Throws:
java.lang.Exception - JoltHTML page objects may throw any exception.

runPage

protected abstract void runPage()
                         throws java.lang.Exception
Methods defined by the derived class that executes the contents of the page.

Throws:
java.lang.Exception - JoltHTML page objects may throw any exception.

run

public void run(HttpPresentationComms comms)
         throws java.lang.Exception
Abstract methods that run all code on the page and output the results to the HTTP client.

Specified by:
run in interface HttpPresentation
Parameters:
comms - HTTP communications object.
Throws:
java.lang.Exception - JoltHTML page objects may throw any exception.
See Also:
HttpPresentationComms

Enhydra 5.1 API