author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Tue, 16 Oct 2012 11:55:56 +0200 | |
changeset 104 | 1376481f15e7 |
parent 100 | 029e6eed60e9 |
child 106 | 346633cd13d6 |
permissions | -rw-r--r-- |
jaroslav@100 | 1 |
package org.apidesign.bck2brwsr.htmlpage; |
jaroslav@100 | 2 |
|
jaroslav@100 | 3 |
import org.apidesign.bck2brwsr.htmlpage.api.OnClick; |
jaroslav@100 | 4 |
import org.apidesign.bck2brwsr.htmlpage.api.Page; |
jaroslav@100 | 5 |
|
jaroslav@100 | 6 |
/** Trivial demo for the bck2brwsr project. First of all start |
jaroslav@100 | 7 |
* with <a href="TestPage.html">your XHTML page</a>. Include there |
jaroslav@100 | 8 |
* a script that will <em>boot Java</em> in your browser. |
jaroslav@100 | 9 |
* <p> |
jaroslav@100 | 10 |
* Then use <code>@Page</code> annotation to |
jaroslav@100 | 11 |
* generate a Java representation of elements with IDs in that page. |
jaroslav@100 | 12 |
* Depending on the type of the elements, they will have different |
jaroslav@100 | 13 |
* methods (e.g. <code>PG_TITLE</code> has <code>setText</code>, etc.). |
jaroslav@100 | 14 |
* Use <code>@OnClick</code> annotation to associate behavior |
jaroslav@100 | 15 |
* with existing elements. Use the generated elements |
jaroslav@100 | 16 |
* (<code>PG_TITLE</code>, <code>PG_TEXT</code>) to modify the page. |
jaroslav@100 | 17 |
* <p> |
jaroslav@100 | 18 |
* Everything is type-safe. As soon as somebody modifies the page and |
jaroslav@100 | 19 |
* removes the IDs or re-assigns them to wrong elements. Java compiler |
jaroslav@100 | 20 |
* will emit an error. |
jaroslav@100 | 21 |
* <p> |
jaroslav@100 | 22 |
* Welcome to the type-safe HTML5 world! |
jaroslav@100 | 23 |
* |
jaroslav@100 | 24 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jaroslav@100 | 25 |
*/ |
jaroslav@100 | 26 |
@Page(xhtml="TestPage.html", name="TestPage") |
jaroslav@100 | 27 |
public class PageController { |
jaroslav@100 | 28 |
@OnClick(id="pg.button") |
jaroslav@100 | 29 |
static void updateTitle() { |
jaroslav@104 | 30 |
TestPage.PG_TITLE.setText("You want this window to be named " + TestPage.PG_TEXT.getValue()); |
jaroslav@100 | 31 |
} |
jaroslav@100 | 32 |
} |