mojo/src/main/resources/archetype-resources/src/main/java/App.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 15 Feb 2013 20:09:36 +0100
branchemul
changeset 744 341d8ed644df
parent 533 715a6c77b19e
permissions -rw-r--r--
Modifying the archetype to generate static ZIP file to be uploaded on a static web server
     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 }