1.1 --- a/json/src/test/java/net/java/html/json/PersonImpl.java Wed Jul 01 23:21:56 2015 +0200
1.2 +++ b/json/src/test/java/net/java/html/json/PersonImpl.java Wed Dec 09 21:39:13 2015 +0100
1.3 @@ -91,26 +91,45 @@
1.4 }
1.5 }
1.6
1.7 - @Model(className = "People", targetId="myPeople", properties = {
1.8 + @Model(className = "People", instance = true, targetId="myPeople", properties = {
1.9 @Property(array = true, name = "info", type = Person.class),
1.10 @Property(array = true, name = "nicknames", type = String.class),
1.11 @Property(array = true, name = "age", type = int.class),
1.12 @Property(array = true, name = "sex", type = Sex.class)
1.13 })
1.14 public static class PeopleImpl {
1.15 - @ModelOperation static void addAge42(People p) {
1.16 + private int addAgeCount;
1.17 + private Runnable onInfoChange;
1.18 +
1.19 + @ModelOperation void onInfoChange(People self, Runnable r) {
1.20 + onInfoChange = r;
1.21 + }
1.22 +
1.23 + @ModelOperation void addAge42(People p) {
1.24 p.getAge().add(42);
1.25 + addAgeCount++;
1.26 }
1.27
1.28 @OnReceive(url = "url", method = "WebSocket", data = String.class)
1.29 - static void innerClass(People p, String d) {
1.30 + void innerClass(People p, String d) {
1.31 }
1.32
1.33 - @Function static void inInnerClass(People p, Person data, int x, double y, String nick) throws IOException {
1.34 + @Function void inInnerClass(People p, Person data, int x, double y, String nick) throws IOException {
1.35 p.getInfo().add(data);
1.36 p.getAge().add(x);
1.37 p.getAge().add((int)y);
1.38 p.getNicknames().add(nick);
1.39 }
1.40 +
1.41 + @ModelOperation void readAddAgeCount(People p, int[] holder, Runnable whenDone) {
1.42 + holder[0] = addAgeCount;
1.43 + whenDone.run();
1.44 + }
1.45 +
1.46 + @OnPropertyChange("age") void infoChange(People p) {
1.47 + if (onInfoChange != null) {
1.48 + onInfoChange.run();
1.49 + }
1.50 + }
1.51 }
1.52 }