javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnReceive.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 08 Apr 2013 16:51:30 +0200
branchmodel
changeset 954 6448c284fe21
parent 934 19b4ddc302a6
child 964 df60ba2aeb87
permissions -rw-r--r--
Support for JSONP
jaroslav@934
     1
/**
jaroslav@934
     2
 * Back 2 Browser Bytecode Translator
jaroslav@934
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@934
     4
 *
jaroslav@934
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@934
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@934
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@934
     8
 *
jaroslav@934
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@934
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@934
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@934
    12
 * GNU General Public License for more details.
jaroslav@934
    13
 *
jaroslav@934
    14
 * You should have received a copy of the GNU General Public License
jaroslav@934
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@934
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@934
    17
 */
jaroslav@934
    18
package org.apidesign.bck2brwsr.htmlpage.api;
jaroslav@934
    19
jaroslav@934
    20
import java.lang.annotation.ElementType;
jaroslav@934
    21
import java.lang.annotation.Retention;
jaroslav@934
    22
import java.lang.annotation.RetentionPolicy;
jaroslav@934
    23
import java.lang.annotation.Target;
jaroslav@934
    24
jaroslav@934
    25
/** Static methods in classes annotated by {@link Model} or {@link Page}
jaroslav@934
    26
 * can be marked by this annotation establish a JSON communication point.
jaroslav@934
    27
 * The associated model page then gets new method to invoke a network
jaroslav@934
    28
 * connection 
jaroslav@934
    29
 * 
jaroslav@934
    30
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@934
    31
 */
jaroslav@934
    32
@Retention(RetentionPolicy.SOURCE)
jaroslav@934
    33
@Target(ElementType.METHOD)
jaroslav@934
    34
public @interface OnReceive {
jaroslav@934
    35
    /** The URL to connect to. Can contain variable names surrounded by '{' and '}'.
jaroslav@934
    36
     * Those parameters will then become variables of the associated method.
jaroslav@934
    37
     * 
jaroslav@934
    38
     * @return the (possibly parametrized) url to connect to
jaroslav@934
    39
     */
jaroslav@934
    40
    String url();
jaroslav@954
    41
    
jaroslav@954
    42
    /** Support for <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a> requires
jaroslav@954
    43
     * a callback from the server generated page to a function defined in the
jaroslav@954
    44
     * system. The name of such function is usually specified as a property
jaroslav@954
    45
     * (of possibly different names). By defining the <code>jsonp</code> attribute
jaroslav@954
    46
     * one turns on the <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a> 
jaroslav@954
    47
     * transmission and specifies the name of the property. The property should
jaroslav@954
    48
     * also be used in the {@link #url()} attribute on appropriate place.
jaroslav@954
    49
     * 
jaroslav@954
    50
     * @return name of a property to carry the name of <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a>
jaroslav@954
    51
     *    callback function.
jaroslav@954
    52
     */
jaroslav@954
    53
    String jsonp() default "";
jaroslav@934
    54
}