|
||
Adding a New PageWe have been able to do a lot just with a "Hello, World" program. Now it's time to add in another page.Adding a page in Jaxcent has three components:
The HTML PageThe HTML page is like any normal HTML page, except that the HEAD section must contain the following:<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. The Java Source CodeTypically, there will be a Java class connected to every HTML page, for doing all AJAX handling. (Though there does not have to be a class and sometimes you can just use the base classjaxcent.JaxcentPage.)
This Java class must derive from the 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. The XML MappingThe HTML page must be connected to the Java class.
This is done by adding a 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 Exercise:
|
||
|