Adding a page in Jaxcent has three components:
This Java class must derive from the
jaxcent.JaxcentPage class. In most
cases, there will be one or more variables declared that refer to
tags on the HTML page. These variables are of type Html<Tag>
where <Tag> refers to the HTML tag those variables match on the page.
When you initialize these variables, the constructor tells Jaxcent how to find the matching HTML element on the HTML page.
We have already seen initializations of the form
HtmlPara p = new HtmlPara( this, "text" );where
"id"attribute of the HTML tag on the HTML page.
There are other search methods available, e.g.
HtmlPara p = new HtmlPara( this, SearchType.SearchByTag, "P", 2 );This refers to the 3rd element on the page with a "P" tag. The searching index is 0-based, so the "2" actually is the third by count. You can omit the last argument, in which case it defaults to 0, i.e. the first such tag. For INPUT elements, there are more search types, e.g.
HtmlInputText text = new HtmlInputText( this, SearchType.SearchByName, "FirstName" );or
HtmlInputText text = new HtmlInputText( this, SearchType.SearchInputByType, "TEXT", 1 );which will find the second INPUT TEXT on the page. You can even search by input value,
HtmlInputText text = new HtmlInputText( this, SearchType.SearchInputByValue, "ok" );which may be useful in searching for checkboxes or radio buttons.
Each variable initialization can also be followed by event over-rides.
Finally, in the Java code, there can be a constructor and over-rides of form load, unload methods.
Processing can start in the constructor or in one of the over-ridden methods.
This is done by adding a
Page node in the Jaxcent XML configuration file.
There are two sub-nodes, a
PagePath that specifies the URL path
(starting with a "/" and usually ending in ".html") of the HTML
file, and a
PageClass that specifies the fully qualified name of the class.
In addition to
PageClass, an AutoSessionData
node with the value true can be added. This tells
Jaxcent to provide automatic forms data management.
The Jaxcent XML configuration file in C:\Jaxtut already contains a sample mapping. Other mappings follow the similar format.
If there is no Java source required (this can be the case
if AutoSessionData is set, and you are using Jaxcent
on that HTML page just for managing forms data), the
PageClass node must
still be present, but it just contains
is the base class.
<SELECT id="mySelect"> </SELECT>
<BUTTON id="myButton">My Button</BUTTON>
<TABLE id="myTable" border=2> </TABLE>
tutorial". Declare and initialize a variable
HtmlTablethat connects to the table, a variable
HtmlSelectthat connects to the SELECT, and a variable
HtmlButtonthat connects to the button. Add a click handler to
showMessageDialog( "Button Clicked" );
Pagenode that connects the HTML page
|Next Step: Working with Tables and Lists|