We write a page that shows "Hello world! , we need to write at least one Page object and a corresponding template file (tml).
The first step is to write the Page object
In Tapestry5, page is a Pojo object that corresponds to a page that does not need to inherit any of the base classes of the tapestry framework or implement any interfaces, but as our business becomes more complex, page increases, There will be additional event handling methods and annotations (callouts) within it.
As the first running first page, the Page object is named "Start", and of course we can also set the name "Start" as the default name, and it must be placed under the "Com.kingbegin.web.pages" package, The Start.java code is shown in the list.
Package
com.kingbegin.web.pages;
public class Start {
private String message;
Public String GetMessage () {return
"Hello world!";
}
}
From the list of programs our message property and the GetMessage method accessed from the message property are available for display in the page.
Step two, write the template file
The template file that corresponds to the Page object Start.java is start.tml, where there are two places where one is placed under the same package as the Page object Start.java <tapestry5-first Engineering path >\src\com\ Kingbegin\web\pages directory, the other place is placed in the Web-inf (<tapestry5-first Engineering path >\webroot\web-inf) directory. The start.tml code is shown in the list.
From the list of programs start.tml the essence of the file is an XHTML file that uses the Tapestry5 namespace--xmlns:t= "Http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" , the expression language "${message}" is also mixed in the template file, the expression language can read the page object data, and in the template file there is also a LABEL element that reflects the control, further implementing the interaction with the Page object.