1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Model.java Wed Apr 10 11:43:46 2013 +0200
1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Model.java Wed Apr 10 12:19:32 2013 +0200
1.3 @@ -27,8 +27,9 @@
1.4 * annotated by {@link ComputedProperty} which define derived
1.5 * properties in the model class.
1.6 * <p>
1.7 - * The {@link #className() generated class} will have methods
1.8 - * to convert the object <code>toJSON</code> and <code>fromJSON</code>.
1.9 + * The {@link #className() generated class}'s <code>toString</code>
1.10 + * converts the state of the object into
1.11 + * <a href="http://en.wikipedia.org/wiki/JSON">JSON</a> format.
1.12 *
1.13 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.14 */
2.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java Wed Apr 10 11:43:46 2013 +0200
2.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java Wed Apr 10 12:19:32 2013 +0200
2.3 @@ -22,12 +22,51 @@
2.4 import java.lang.annotation.RetentionPolicy;
2.5 import java.lang.annotation.Target;
2.6
2.7 -/** Static methods in classes annotated by {@link Model} or {@link Page}
2.8 - * can be marked by this annotation establish a JSON communication point.
2.9 +/** Static methods in classes annotated by {@link Page}
2.10 + * can be marked by this annotation to establish a
2.11 + * <a href="http://en.wikipedia.org/wiki/JSON">JSON</a>
2.12 + * communication point.
2.13 * The associated model page then gets new method to invoke a network
2.14 - * connection
2.15 + * connection. Example follows:
2.16 + *
2.17 + * <pre>
2.18 + * {@link Page @Page}(className="MyModel", xhtml="page.html", properties={
2.19 + * {@link Property @Property}(name = "people", type=Person.class, array=true)
2.20 + * })
2.21 + * class MyModelImpl {
2.22 + * {@link Model @Model}(className="Person", properties={
2.23 + * {@link Property @Property}(name = "firstName", type=String.class),
2.24 + * {@link Property @Property}(name = "lastName", type=String.class)
2.25 + * })
2.26 + * static class PersonImpl {
2.27 + * {@link ComputedProperty @ComputedProperty}
2.28 + * static String fullName(String firstName, String lastName) {
2.29 + * return firstName + " " + lastName;
2.30 + * }
2.31 + * }
2.32 + *
2.33 + * {@link OnReceive @OnReceive}(url = "{protocol}://your.server.com/person/{name}")
2.34 + * static void getANewPerson(MyModel m, Person p) {
2.35 + * {@link Element#alert Element.alert}("Adding " + p.getFullName() + '!');
2.36 + * m.getPeople().add(p);
2.37 + * }
2.38 + *
2.39 + * // the above will generate method <code>getANewPerson</code> in class <code>MyModel</code>.
2.40 + * // with <code>protocol</code> and <code>name</code> arguments
2.41 + * // which asynchronously contacts the server and in case of success calls
2.42 + * // your {@link OnReceive @OnReceive} with parsed in data
2.43 + *
2.44 + * {@link On @On}(event={@link OnEvent#CLICK OnEvent.CLICK}, id="rqst")
2.45 + * static void requestSmith(MyModel m) {
2.46 + * m.getANewPerson("http", "Smith");
2.47 + * }
2.48 + * }
2.49 + * </pre>
2.50 + * When the server returns <code>{ "firstName" : "John", "lastName" : "Smith" }</code>
2.51 + * the browser will show alert message <em>Adding John Smith!</em>.
2.52 *
2.53 * @author Jaroslav Tulach <jtulach@netbeans.org>
2.54 + * @since 0.6
2.55 */
2.56 @Retention(RetentionPolicy.SOURCE)
2.57 @Target(ElementType.METHOD)