In JSF, write a Hello world that appears on the page

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.