rt/archetype/src/main/resources/archetype-resources/src/main/java/App.java
changeset 870 448bed1f6d5a
parent 772 d382dacfd73f
child 893 20fb32569339
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/main/java/App.java	Fri Mar 22 00:02:21 2013 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +package ${package};
     1.5 +
     1.6 +import org.apidesign.bck2brwsr.htmlpage.api.*;
     1.7 +import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
     1.8 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
     1.9 +import org.apidesign.bck2brwsr.htmlpage.api.Property;
    1.10 +import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
    1.11 +
    1.12 +/** Edit the index.xhtml file. Use 'id' to name certain HTML elements.
    1.13 + * Use this class to define behavior of the elements.
    1.14 + */
    1.15 +@Page(xhtml="index.html", className="Index", properties={
    1.16 +    @Property(name="name", type=String.class)
    1.17 +})
    1.18 +public class App {
    1.19 +    static {
    1.20 +        Index model = new Index();
    1.21 +        model.setName("World");
    1.22 +        model.applyBindings();
    1.23 +    }
    1.24 +    
    1.25 +    @On(event = CLICK, id="hello")
    1.26 +    static void hello(Index m) {
    1.27 +        GraphicsContext g = m.CANVAS.getContext();
    1.28 +        g.clearRect(0, 0, 1000, 1000);
    1.29 +        g.setFont("italic 40px Calibri");
    1.30 +        g.fillText(m.getHelloMessage(), 10, 40);
    1.31 +    }
    1.32 +    
    1.33 +    @ComputedProperty
    1.34 +    static String helloMessage(String name) {
    1.35 +        return "Hello " + name + "!";
    1.36 +    }
    1.37 +}