diff -r 6448c284fe21 -r df60ba2aeb87 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java Mon Apr 08 16:51:30 2013 +0200 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java Wed Apr 10 12:19:32 2013 +0200 @@ -22,12 +22,51 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** Static methods in classes annotated by {@link Model} or {@link Page} - * can be marked by this annotation establish a JSON communication point. +/** Static methods in classes annotated by {@link Page} + * can be marked by this annotation to establish a + * JSON + * communication point. * The associated model page then gets new method to invoke a network - * connection + * connection. Example follows: + * + *
+ * {@link Page @Page}(className="MyModel", xhtml="page.html", properties={ + * {@link Property @Property}(name = "people", type=Person.class, array=true) + * }) + * class MyModelImpl { + * {@link Model @Model}(className="Person", properties={ + * {@link Property @Property}(name = "firstName", type=String.class), + * {@link Property @Property}(name = "lastName", type=String.class) + * }) + * static class PersonImpl { + * {@link ComputedProperty @ComputedProperty} + * static String fullName(String firstName, String lastName) { + * return firstName + " " + lastName; + * } + * } + * + * {@link OnReceive @OnReceive}(url = "{protocol}://your.server.com/person/{name}") + * static void getANewPerson(MyModel m, Person p) { + * {@link Element#alert Element.alert}("Adding " + p.getFullName() + '!'); + * m.getPeople().add(p); + * } + * + * // the above will generate method+ * When the server returnsgetANewPerson
in classMyModel
. + * // withprotocol
andname
arguments + * // which asynchronously contacts the server and in case of success calls + * // your {@link OnReceive @OnReceive} with parsed in data + * + * {@link On @On}(event={@link OnEvent#CLICK OnEvent.CLICK}, id="rqst") + * static void requestSmith(MyModel m) { + * m.getANewPerson("http", "Smith"); + * } + * } + *
{ "firstName" : "John", "lastName" : "Smith" }
+ * the browser will show alert message Adding John Smith!.
*
* @author Jaroslav Tulach