net.server.servlets
Class HtmlPage

java.lang.Object
  extended by net.server.servlets.HtmlPage
Direct Known Subclasses:
ReviewForm

public class HtmlPage
extends java.lang.Object

The HtmlPage class encapsulates the functionality required to prepare an HTML script to display in a browser. This class provides methods to construct various HTML elements such as forms, list boxes, anchor tags and headlines.

Version:
1.00
Author:
Robert Lysik

Constructor Summary
HtmlPage()
          This is the default constructor for the HtmlPage class.
HtmlPage(java.lang.String title)
          This constructor takes a String as an argument which is used to initialize the title of the page.
 
Method Summary
 void addBreak()
          This function inserts a line break into the HTML script.
 void addHeadline(int headlineType, java.lang.String headlineText)
          This function inserts a headline tag with the value provided as a parameter to the function, as well as the text to be displayed.
 void addHidden(java.lang.String name, java.lang.String value)
          This function inserts a hidden input control tag into the HTML script.
 void addInput(java.lang.String type, java.lang.String name, java.lang.String value, java.lang.String size)
          This function creates an input element for a form.
 void addSubmit(java.lang.String value)
          This function adds submit button to a form in an HTML page.
 void addText(java.lang.String text)
          This function adds a normal text string to the HTML script.
 void endForm()
          This function adds a closing form HTML tag.
 java.lang.String getHtml()
          This function returns the HTML script to generate the page as it is currently defined.
 java.lang.String getSelect(java.lang.String name, java.lang.String size, java.lang.String[] values, java.lang.String[] text)
          This function creates an input element which is called a select list.
 java.lang.String quote(java.lang.String s)
          This function returns a string which is surrounded by quotes.
 void startForm(java.lang.String method, java.lang.String action)
          This function inserts the opening tag for a form into the HTML script.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlPage

public HtmlPage()
This is the default constructor for the HtmlPage class. An empty title tag is provided for the title string, as well as the opening tag for the body section of the HTML page.


HtmlPage

public HtmlPage(java.lang.String title)
This constructor takes a String as an argument which is used to initialize the title of the page.

Parameters:
String - the title of the page
Method Detail

addBreak

public void addBreak()
This function inserts a line break into the HTML script.


addHeadline

public void addHeadline(int headlineType,
                        java.lang.String headlineText)
This function inserts a headline tag with the value provided as a parameter to the function, as well as the text to be displayed.

Parameters:
int - the headline type
String - the headline text

addHidden

public void addHidden(java.lang.String name,
                      java.lang.String value)
This function inserts a hidden input control tag into the HTML script.

Parameters:
String - name of hidden tag
String - value of hidden tag

addInput

public void addInput(java.lang.String type,
                     java.lang.String name,
                     java.lang.String value,
                     java.lang.String size)
This function creates an input element for a form. Input elements, such as text boxes, radio buttons, and checkboxes allow the user of an HTML page to enter information which may then be processed by another page, or by script within the existing page. These elements must be enclosed within form tags in order for correct processing.

Parameters:
String - the type of form input, i.e. text, radio, checkbox
String - the name of the input element
String - the value associated with this element
String - the size of the element

addSubmit

public void addSubmit(java.lang.String value)
This function adds submit button to a form in an HTML page.

Parameters:
String - the text to be displayed on the submit button

addText

public void addText(java.lang.String text)
This function adds a normal text string to the HTML script.

Parameters:
String - the text to be displayed

endForm

public void endForm()
This function adds a closing form HTML tag.


getHtml

public java.lang.String getHtml()
This function returns the HTML script to generate the page as it is currently defined. The title and body elements of the HTML page are enclosed in opening and closing HTML tags.


getSelect

public java.lang.String getSelect(java.lang.String name,
                                  java.lang.String size,
                                  java.lang.String[] values,
                                  java.lang.String[] text)
This function creates an input element which is called a select list. This is a drop down list box, if the size of the list box is set to one, or a normal list box if the size is greater than one. This element must be encapsulated within the FORM section of an HTML page in order for correct processing to occur.

Parameters:
String - the name of the select list
String - the size of the select list. If set to one, this becomes a drop down list box.
String - the values associated with the list box
String - the text displayed in the list box.

quote

public java.lang.String quote(java.lang.String s)
This function returns a string which is surrounded by quotes.

Parameters:
String - the string to be encapsulated in quotes

startForm

public void startForm(java.lang.String method,
                      java.lang.String action)
This function inserts the opening tag for a form into the HTML script.

Parameters:
String - the method of form submission, either post or get.
String - the action attribute of the form.