json/src/main/java/net/java/html/json/Models.java
branchstorage
changeset 715 e02a21e93241
parent 655 7211ec5f3172
     1.1 --- a/json/src/main/java/net/java/html/json/Models.java	Mon May 19 13:42:49 2014 +0200
     1.2 +++ b/json/src/main/java/net/java/html/json/Models.java	Tue Jul 08 07:16:11 2014 +0200
     1.3 @@ -141,4 +141,45 @@
     1.4      public static void applyBindings(Object model) {
     1.5          JSON.applyBindings(model);
     1.6      }
     1.7 +    
     1.8 +    /** Stores the model value into local storage. Works in
     1.9 +     * orchestration with 
    1.10 +     * {@link #getItem(net.java.html.BrwsrCtx, java.lang.String, java.lang.Class)}
    1.11 +     * method. The storage implementation may differ, but should
    1.12 +     * closely mimic the behaviour of <a href="http://www.w3.org/TR/webstorage/">webstorage</a>
    1.13 +     * specification.
    1.14 +     * 
    1.15 +     * @param <Model> the class generated by {@link Model} annotation
    1.16 +     *   or ({@link String}
    1.17 +     * @param key string representing the key to place the model value to
    1.18 +     *   in the storage
    1.19 +     * @param model a non-<code>null</code> instance to place into the storage
    1.20 +     * @return <code>true</code> if the value was persistently stored,
    1.21 +     *   <code>false</code> if the value is available only for current execution
    1.22 +     *   of the application
    1.23 +     * 
    1.24 +     * @since 0.8.3
    1.25 +     */
    1.26 +    public static <Model> boolean putItem(String key, Model model) {
    1.27 +        return false;
    1.28 +    }
    1.29 +    
    1.30 +    /** Obtains a value from a local storage. The value should have been
    1.31 +     * previously stored by {@link #putItem(java.lang.String, java.lang.Object)}
    1.32 +     * method. The storage implementation may differ, but should
    1.33 +     * closely mimic the behaviour of <a href="http://www.w3.org/TR/webstorage/">webstorage</a>
    1.34 +     * specification.
    1.35 +     * 
    1.36 +     * @param <Model> type generated by {@link Model} annotation or {@link String}
    1.37 +     * @param ctx the browser context to use for the newly instantiated instance
    1.38 +     * @param key string representing the slot to read from the storage
    1.39 +     * @param clazz class generated by {@link Model} annotation or {@link String}
    1.40 +     * @return the instance of the model filled by the value found under 
    1.41 +     *   the key or <code>null</code> if no such key/value was found in 
    1.42 +     *   the storage
    1.43 +     * @since 0.8.3
    1.44 +     */
    1.45 +    public static <Model> Model getItem(BrwsrCtx ctx, String key, Class<Model> clazz) {
    1.46 +        return null;
    1.47 +    }
    1.48  }