mojo/src/main/resources/archetype-resources/src/main/java/App.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 22 Jan 2013 09:19:47 +0100
branchmodel
changeset 528 08cd5a0c967e
parent 437 d7ec46950980
child 533 715a6c77b19e
permissions -rw-r--r--
Archetype using the @Property model
     1 package ${package};
     2 
     3 import org.apidesign.bck2brwsr.htmlpage.api.*;
     4 import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
     5 import org.apidesign.bck2brwsr.htmlpage.api.Page;
     6 import org.apidesign.bck2brwsr.htmlpage.api.Property;
     7 import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
     8 
     9 /** Edit the index.xhtml file. Use 'id' to name certain HTML elements.
    10  * Use this class to define behavior of the elements.
    11  */
    12 @Page(xhtml="index.xhtml", className="Index", properties={
    13     @Property(name="name", type=String.class)
    14 })
    15 public class App {
    16     static {
    17         Index model = new Index();
    18         model.setName("World");
    19         model.applyBindings();
    20     }
    21     
    22     @On(event = CLICK, id="hello")
    23     static void hello(Index m) {
    24         Element.alert(m.getHelloMessage());
    25     }
    26     
    27     @ComputedProperty
    28     static String helloMessage(String name) {
    29         return "Hello " + name + "!";
    30     }
    31 }