Adding a page in Jaxcent has three components:
<SCRIPT TYPE="text/javascript" SRC="/jaxcent21.js"> </SCRIPT>This is very important. If you are doing Jaxcent programming, and you visit a new page and nothing happens, check if you are missing the JavaScript include! Other errors may cause some sort of alarm, but this error will silently fail. But if this include statement is missing, the page will not be connected to Jaxcent, and nothing will happen.
jaxcent.JaxcentPage.)
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.
E.g. HtmlPara, HtmlInputText, HtmlInputButton,
HtmlForm etc.
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 "text" matches the "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 PagePath and 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 jaxcent.JaxcentPage which
is the base class.
Exercise:
<SELECT id="mySelect"> </SELECT>
<BUTTON id="myButton">My Button</BUTTON>
<TABLE id="myTable" border=2> </TABLE>
tutorial".
Declare and initialize a variable myTable of type
HtmlTable that connects to the table, a variable
mySelect of type HtmlSelect that
connects to the SELECT, and a variable myButton
of type HtmlButton
that connects to the button. Add a click handler to myButton
that calls
showMessageDialog( "Button Clicked" );
Page node that connects the HTML page
/MyPage.html to the tutorial.MyPage
Java class.
| Next Step: Working with Tables and Lists |