1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/java/DataModel.java Mon Sep 09 17:34:30 2013 +0200
1.3 @@ -0,0 +1,31 @@
1.4 +package ${package};
1.5 +
1.6 +import net.java.html.json.ComputedProperty;
1.7 +import net.java.html.json.Function;
1.8 +import net.java.html.json.Model;
1.9 +import net.java.html.json.Property;
1.10 +
1.11 +/** Model annotation generates class Data with
1.12 + * one message property, boolean property and read only words property
1.13 + */
1.14 +@Model(className = "Data", properties = {
1.15 + @Property(name = "message", type = String.class),
1.16 + @Property(name = "on", type = boolean.class)
1.17 +})
1.18 +final class DataModel {
1.19 + @ComputedProperty static java.util.List<String> words(String message) {
1.20 + String[] arr = new String[6];
1.21 + String[] words = message == null ? new String[0] : message.split(" ", 6);
1.22 + for (int i = 0; i < 6; i++) {
1.23 + arr[i] = words.length > i ? words[i] : "!";
1.24 + }
1.25 + return java.util.Arrays.asList(arr);
1.26 + }
1.27 +
1.28 + @Function static void turnOn(Data model) {
1.29 + model.setOn(true);
1.30 + }
1.31 + @Function static void turnOff(Data model) {
1.32 + model.setOn(false);
1.33 + }
1.34 +}