com.cometway.httpd
Class XHTMLFormWriter

java.lang.Object
  extended by com.cometway.httpd.HTMLFormWriter
      extended by com.cometway.httpd.XHTMLFormWriter

public class XHTMLFormWriter
extends HTMLFormWriter

XHTMLFormWriter is a tool for writing simple XHTML-based forms to a StringBuffer or AgentRequest output stream. Using this class it is relatively simple to create generic forms without worrying about the XHTML code.


Constructor Summary
XHTMLFormWriter(AgentRequest agentRequest)
          Use this constructor to write XHTML and CSS forms directly to an AgentRequest.
XHTMLFormWriter(java.lang.StringBuffer b)
          Use this constructor to write XHTML forms to a StringBuffer.
 
Method Summary
protected  java.lang.String encode(java.lang.String in)
           
 void writeCaption(java.lang.String caption)
          Adds a caption to the form output.
 void writeCheckbox(java.lang.String label, java.lang.String name, boolean checked)
          Writes a checkbox to the form output.
 void writeField(java.lang.String label, java.lang.String name, int size)
          Writes a standard input field to the form output.
 void writeField(java.lang.String label, java.lang.String name, Props p, int size)
          Writes a standard input field to the form output displaying the value as retrieved from the Props using the specified name as the Props key.
 void writeField(java.lang.String label, java.lang.String name, java.lang.String value, int size)
          Writes a standard input field to the form output displaying the specified value.
 void writeFooter()
          Writes the form footer to the output.
 void writeHeader(java.lang.String submitURL)
          Writes the form header to the output.
 void writeHeader(java.lang.String submitURL, Props userProps)
          Writes the form header to the output.
 void writeHelp(java.lang.String message)
          Adds a help description over the fields.
 void writeHiddenField(java.lang.String name, Props p)
          Writes a hidden input parameter to the form output as retrieved from the Props using the specified name as the Props key.
 void writeHiddenField(java.lang.String name, java.lang.String value)
          Writes a hidden input parameter to the form output.
protected  void writeLabel(java.lang.String title)
           
protected  void writeLabel(java.lang.String title, java.lang.String name)
           
 void writeLoginFields(Props p)
          Hidden "login_name" and "login_hash" parameters are added to the form output using the "name" and "password" values of the specified Props.
 void writeLoginFields(java.lang.String name, java.lang.String password)
          Hidden "login_name" and "login_hash" parameters are added to the form output using the specified name and password.
 void writeMultilineField(java.lang.String label, java.lang.String name, int columns, int rows)
          Writes a multiline field (TEXTAREA) to the form output.
 void writeMultilineField(java.lang.String label, java.lang.String name, Props p, int columns, int rows)
          Writes a multiline field (TEXTAREA) to the form output displaying the specified value as retrieved from the Props using the specified name as a key.
 void writeMultilineField(java.lang.String label, java.lang.String name, java.lang.String value, int columns, int rows)
          Writes a multiline field (TEXTAREA) to the form output displaying the specified value.
 void writePassword(java.lang.String label, java.lang.String name, int size)
          Writes a password input field to the form output.
 void writePassword(java.lang.String label, java.lang.String name, java.lang.String value, int size)
          Writes a password input field to the form output containing the specified value.
 void writeProps(Props p)
          Writes a table containing the Props keys and associated values to the output.
 void writeResetButton(java.lang.String title, java.lang.String description)
          Writes a reset button and description to the form output that resets changes to the form when pressed.
 void writeSelectFooter()
          Writes the footer XHTML for a SELECT to the form output.
 void writeSelectHeader(java.lang.String label, java.lang.String name, boolean multiple)
          Writes the header XHTML for a SELECT to the form output to display a popup menu or selection list.
 void writeSelectItem(java.lang.String name, java.lang.String value, boolean selected)
          Writes a SELECT OPTION to the form output.
 void writeSelectItem(java.lang.String name, java.lang.String value, java.lang.String currentSelection)
          Writes a SELECT OPTION to the form output.
 void writeSpace()
          Writes appropriate XHTML to the output to add vertical space between form items.
 void writeStaticField(java.lang.String label, java.lang.String value)
          Writes a static text field to the form output.
 void writeStaticField(java.lang.String label, java.lang.String name, java.lang.String value, int size)
          Writes a static text field to the form output.
 void writeSubmitButton(java.lang.String title, java.lang.String name, java.lang.String description)
          Writes a submit button and description to the form output.
 
Methods inherited from class com.cometway.httpd.HTMLFormWriter
print, print, println, println, writeCheckbox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XHTMLFormWriter

public XHTMLFormWriter(AgentRequest agentRequest)
Use this constructor to write XHTML and CSS forms directly to an AgentRequest.


XHTMLFormWriter

public XHTMLFormWriter(java.lang.StringBuffer b)
Use this constructor to write XHTML forms to a StringBuffer.

Method Detail

writeCaption

public void writeCaption(java.lang.String caption)
                  throws java.io.IOException
Adds a caption to the form output.

Overrides:
writeCaption in class HTMLFormWriter
Throws:
java.io.IOException

writeCheckbox

public void writeCheckbox(java.lang.String label,
                          java.lang.String name,
                          boolean checked)
                   throws java.io.IOException
Writes a checkbox to the form output.

Overrides:
writeCheckbox in class HTMLFormWriter
Throws:
java.io.IOException

writeFooter

public void writeFooter()
                 throws java.io.IOException
Writes the form footer to the output. Call this method last to properly terminate the form XHTML.

Overrides:
writeFooter in class HTMLFormWriter
Throws:
java.io.IOException

writeHeader

public void writeHeader(java.lang.String submitURL)
                 throws java.io.IOException
Writes the form header to the output. Call this method first to properly begin the form XHTML. This creates a POST type request to the specified submitURL.

Overrides:
writeHeader in class HTMLFormWriter
Throws:
java.io.IOException

writeHeader

public void writeHeader(java.lang.String submitURL,
                        Props userProps)
                 throws java.io.IOException
Writes the form header to the output. Call this method first to properly begin the form XHTML. This creates a POST type request to the specified submitURL. Hidden "login_name" and "login_hash" parameters are added to the form for the specified userProps.

Overrides:
writeHeader in class HTMLFormWriter
Throws:
java.io.IOException

writeHelp

public void writeHelp(java.lang.String message)
               throws java.io.IOException
Adds a help description over the fields.

Overrides:
writeHelp in class HTMLFormWriter
Throws:
java.io.IOException

writeSpace

public void writeSpace()
                throws java.io.IOException
Writes appropriate XHTML to the output to add vertical space between form items.

Overrides:
writeSpace in class HTMLFormWriter
Throws:
java.io.IOException

writeField

public void writeField(java.lang.String label,
                       java.lang.String name,
                       int size)
                throws java.io.IOException
Writes a standard input field to the form output.

Overrides:
writeField in class HTMLFormWriter
Throws:
java.io.IOException

writeField

public void writeField(java.lang.String label,
                       java.lang.String name,
                       java.lang.String value,
                       int size)
                throws java.io.IOException
Writes a standard input field to the form output displaying the specified value.

Overrides:
writeField in class HTMLFormWriter
Throws:
java.io.IOException

writeField

public void writeField(java.lang.String label,
                       java.lang.String name,
                       Props p,
                       int size)
                throws java.io.IOException
Writes a standard input field to the form output displaying the value as retrieved from the Props using the specified name as the Props key.

Overrides:
writeField in class HTMLFormWriter
Throws:
java.io.IOException

writeHiddenField

public void writeHiddenField(java.lang.String name,
                             java.lang.String value)
                      throws java.io.IOException
Writes a hidden input parameter to the form output.

Overrides:
writeHiddenField in class HTMLFormWriter
Throws:
java.io.IOException

writeHiddenField

public void writeHiddenField(java.lang.String name,
                             Props p)
                      throws java.io.IOException
Writes a hidden input parameter to the form output as retrieved from the Props using the specified name as the Props key.

Overrides:
writeHiddenField in class HTMLFormWriter
Throws:
java.io.IOException

writeLoginFields

public void writeLoginFields(java.lang.String name,
                             java.lang.String password)
                      throws java.io.IOException
Hidden "login_name" and "login_hash" parameters are added to the form output using the specified name and password.

Overrides:
writeLoginFields in class HTMLFormWriter
Throws:
java.io.IOException

writeLoginFields

public void writeLoginFields(Props p)
                      throws java.io.IOException
Hidden "login_name" and "login_hash" parameters are added to the form output using the "name" and "password" values of the specified Props.

Overrides:
writeLoginFields in class HTMLFormWriter
Throws:
java.io.IOException

writeMultilineField

public void writeMultilineField(java.lang.String label,
                                java.lang.String name,
                                int columns,
                                int rows)
                         throws java.io.IOException
Writes a multiline field (TEXTAREA) to the form output.

Overrides:
writeMultilineField in class HTMLFormWriter
Throws:
java.io.IOException

writeMultilineField

public void writeMultilineField(java.lang.String label,
                                java.lang.String name,
                                java.lang.String value,
                                int columns,
                                int rows)
                         throws java.io.IOException
Writes a multiline field (TEXTAREA) to the form output displaying the specified value.

Overrides:
writeMultilineField in class HTMLFormWriter
Throws:
java.io.IOException

writeMultilineField

public void writeMultilineField(java.lang.String label,
                                java.lang.String name,
                                Props p,
                                int columns,
                                int rows)
                         throws java.io.IOException
Writes a multiline field (TEXTAREA) to the form output displaying the specified value as retrieved from the Props using the specified name as a key.

Overrides:
writeMultilineField in class HTMLFormWriter
Throws:
java.io.IOException

writePassword

public void writePassword(java.lang.String label,
                          java.lang.String name,
                          int size)
                   throws java.io.IOException
Writes a password input field to the form output.

Overrides:
writePassword in class HTMLFormWriter
Throws:
java.io.IOException

writePassword

public void writePassword(java.lang.String label,
                          java.lang.String name,
                          java.lang.String value,
                          int size)
                   throws java.io.IOException
Writes a password input field to the form output containing the specified value.

Overrides:
writePassword in class HTMLFormWriter
Throws:
java.io.IOException

writeProps

public void writeProps(Props p)
                throws java.io.IOException
Writes a table containing the Props keys and associated values to the output. This is useful for debugging the contents of AgentRequest Props.

Overrides:
writeProps in class HTMLFormWriter
Throws:
java.io.IOException

writeResetButton

public void writeResetButton(java.lang.String title,
                             java.lang.String description)
                      throws java.io.IOException
Writes a reset button and description to the form output that resets changes to the form when pressed.

Overrides:
writeResetButton in class HTMLFormWriter
Throws:
java.io.IOException

writeSelectFooter

public void writeSelectFooter()
                       throws java.io.IOException
Writes the footer XHTML for a SELECT to the form output.

Overrides:
writeSelectFooter in class HTMLFormWriter
Throws:
java.io.IOException

writeSelectHeader

public void writeSelectHeader(java.lang.String label,
                              java.lang.String name,
                              boolean multiple)
                       throws java.io.IOException
Writes the header XHTML for a SELECT to the form output to display a popup menu or selection list. The multiple parameter should be set to false for a popup; set it to true to create a selection list. A call to this method is typically followed by multiple calls to writeSelectItem followed by a call to writeSelectFooter to terminate the SELECT.

Overrides:
writeSelectHeader in class HTMLFormWriter
Throws:
java.io.IOException

writeSelectItem

public void writeSelectItem(java.lang.String name,
                            java.lang.String value,
                            boolean selected)
                     throws java.io.IOException
Writes a SELECT OPTION to the form output. Calls to this method must be surrounded by calls to writeSelectHeader and writeSelectFooter.

Overrides:
writeSelectItem in class HTMLFormWriter
Throws:
java.io.IOException

writeSelectItem

public void writeSelectItem(java.lang.String name,
                            java.lang.String value,
                            java.lang.String currentSelection)
                     throws java.io.IOException
Writes a SELECT OPTION to the form output. If the name is equal to the currentSelection the item is selected; otherwise it is not selected. Calls to this method must be surrounded by calls to writeSelectHeader and writeSelectFooter.

Overrides:
writeSelectItem in class HTMLFormWriter
Throws:
java.io.IOException

writeStaticField

public void writeStaticField(java.lang.String label,
                             java.lang.String value)
                      throws java.io.IOException
Writes a static text field to the form output.

Overrides:
writeStaticField in class HTMLFormWriter
Throws:
java.io.IOException

writeStaticField

public void writeStaticField(java.lang.String label,
                             java.lang.String name,
                             java.lang.String value,
                             int size)
                      throws java.io.IOException
Writes a static text field to the form output.

Throws:
java.io.IOException

writeSubmitButton

public void writeSubmitButton(java.lang.String title,
                              java.lang.String name,
                              java.lang.String description)
                       throws java.io.IOException
Writes a submit button and description to the form output.

Overrides:
writeSubmitButton in class HTMLFormWriter
Throws:
java.io.IOException

encode

protected java.lang.String encode(java.lang.String in)
Overrides:
encode in class HTMLFormWriter

writeLabel

protected void writeLabel(java.lang.String title)
                   throws java.io.IOException
Throws:
java.io.IOException

writeLabel

protected void writeLabel(java.lang.String title,
                          java.lang.String name)
                   throws java.io.IOException
Throws:
java.io.IOException