htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageController.java
branchemul
changeset 100 029e6eed60e9
child 104 1376481f15e7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageController.java	Thu Oct 11 06:15:22 2012 -0700
     1.3 @@ -0,0 +1,32 @@
     1.4 +package org.apidesign.bck2brwsr.htmlpage;
     1.5 +
     1.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnClick;
     1.7 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
     1.8 +
     1.9 +/** Trivial demo for the bck2brwsr project. First of all start
    1.10 + * with <a href="TestPage.html">your XHTML page</a>. Include there
    1.11 + * a script that will <em>boot Java</em> in your browser.
    1.12 + * <p>
    1.13 + * Then use <code>@Page</code> annotation to 
    1.14 + * generate a Java representation of elements with IDs in that page.
    1.15 + * Depending on the type of the elements, they will have different 
    1.16 + * methods (e.g. <code>PG_TITLE</code> has <code>setText</code>, etc.).
    1.17 + * Use <code>@OnClick</code> annotation to associate behavior
    1.18 + * with existing elements. Use the generated elements
    1.19 + * (<code>PG_TITLE</code>, <code>PG_TEXT</code>) to modify the page.
    1.20 + * <p>
    1.21 + * Everything is type-safe. As soon as somebody modifies the page and
    1.22 + * removes the IDs or re-assigns them to wrong elements. Java compiler
    1.23 + * will emit an error.
    1.24 + * <p>
    1.25 + * Welcome to the type-safe HTML5 world!
    1.26 + *
    1.27 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.28 + */
    1.29 +@Page(xhtml="TestPage.html", name="TestPage")
    1.30 +public class PageController {
    1.31 +    @OnClick(id="pg.button")
    1.32 +    static void updateTitle() {
    1.33 +        TestPage.PG_TITLE.setText(TestPage.PG_TEXT.getValue());
    1.34 +    }
    1.35 +}