Vous êtes sur la page 1sur 2

Appendix B

Web Application Development Support


Package

This appendix describes the Java classes HtmlPage, HtmlForm, etc, which can
be used (particularly in Servlet-based systems) to generate web pages as part
of an internet application.
Figure B.1 shows the classes involved and their relationships.
HtmlComponent

Htmlltem

HtmlText

HtmlInput

HtmlBody

HtmlHead

HtmlPage

HtmiForm

HtmlTable

HtmlTableData

HtmlTableRow

Figure B.I: Classes for HTML generation

HtmlBody

This describes the body of an HTML page, as a sequence of HTML


A component is added to the end of the body by the add(
component: HtmlComponent) method.

components.

HtmlComponent This is the superclass of all the classes describing HTML


elements. It defines a collection of attribute-value pairs which can be altered
by the setAttribute(att : String, val : String) method. Such pairs appear as
HTML attribute settings att = val in the tag of the HTML component.
The method getHtml() : String returns the ASCII text of the HTML comportent, which can then be sent to a web browser for display.
HtmlForm This class describes HTML forms, as a list of HTML components
within < form > and < / f o r m > tags. The method and action of the form can
329

Appendix B. Web Application Development Support Package

330

be set as attributes using setAttribute.

HtmlHead This class describes the head tag of an H T M L page. The title of
the document is supplied as a string p a r a m e t e r in the constructor, eg:
HtmlHead

head

= new HtmlHead("hdd

entry");

Htmllnput Describes an input element such as a text entry field or b u t t o n for


use within a form. The type (such as text, password or submit) is defined using
setAttribute, as are the other attributes of the element.
Htmlltem This describes single-line H T M L elements such as the p a r a g r a p h
marker < p > or horizontal rule < hr >. The tag is specified in the constructor,
eg:
HtmlItem

para

= new HtmlItem("p")

for a paragraph.

HtmlPage This class describes complete web pages, with a header in HtmlHead
and a body in HtmlBody. The methods setHead(head : HtmIHead) and
setBody(body : HtmlBody) set these elements of the page.
HtmlTable This represents H T M L tables. It consists of a list of HtmITableRow
instances, a new row is added at the end of the table by the method addRow(
row : HtmlTableRow).
HtmlTableData This represents a cell in an H T M L table, most commonly, a
single piece of text. In the latter case the text is supplied as a p a r a m e t e r of
the constructor: HtmlTableData(text:String).
HtmlTableRow This represents a row of an H T M L table. It consists of a list
of cells which are HtmlTableData instances. A new cell is added to the end of
the row by the method addCell(cell : HtmlTableData).
HtmlText This describes text components. The text string and the tag are
supplied in the constructor HtmlText(text: String, tag : String). For example:
HtmlText

nameLabel

= new HtmlText("Name:","strong")

generates the text "Name:" in boldface font. Other qualifiers, such as font size
and colour, can be defined using setAttribute.