rt/archetype/src/main/resources/archetype-resources/src/main/java/App.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 22 Mar 2013 00:02:21 +0100
changeset 870 448bed1f6d5a
parent 772 rt/mojo/src/main/resources/archetype-resources/src/main/java/App.java@d382dacfd73f
child 893 20fb32569339
permissions -rw-r--r--
Separating the archetype into its own module - to give it better name among archetypes
     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.html", 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         GraphicsContext g = m.CANVAS.getContext();
    25         g.clearRect(0, 0, 1000, 1000);
    26         g.setFont("italic 40px Calibri");
    27         g.fillText(m.getHelloMessage(), 10, 40);
    28     }
    29     
    30     @ComputedProperty
    31     static String helloMessage(String name) {
    32         return "Hello " + name + "!";
    33     }
    34 }