jtulach@0
|
1 |
/**
|
jaroslav@358
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
jtulach@0
|
3 |
*
|
jaroslav@551
|
4 |
* Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
|
jtulach@0
|
5 |
*
|
jaroslav@358
|
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
jaroslav@358
|
7 |
* Other names may be trademarks of their respective owners.
|
jtulach@0
|
8 |
*
|
jaroslav@358
|
9 |
* The contents of this file are subject to the terms of either the GNU
|
jaroslav@358
|
10 |
* General Public License Version 2 only ("GPL") or the Common
|
jaroslav@358
|
11 |
* Development and Distribution License("CDDL") (collectively, the
|
jaroslav@358
|
12 |
* "License"). You may not use this file except in compliance with the
|
jaroslav@358
|
13 |
* License. You can obtain a copy of the License at
|
jaroslav@358
|
14 |
* http://www.netbeans.org/cddl-gplv2.html
|
jaroslav@358
|
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
jaroslav@358
|
16 |
* specific language governing permissions and limitations under the
|
jaroslav@358
|
17 |
* License. When distributing the software, include this License Header
|
jaroslav@358
|
18 |
* Notice in each file and include the License file at
|
jaroslav@358
|
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
jaroslav@358
|
20 |
* particular file as subject to the "Classpath" exception as provided
|
jaroslav@358
|
21 |
* by Oracle in the GPL Version 2 section of the License file that
|
jaroslav@358
|
22 |
* accompanied this code. If applicable, add the following below the
|
jaroslav@358
|
23 |
* License Header, with the fields enclosed by brackets [] replaced by
|
jaroslav@358
|
24 |
* your own identifying information:
|
jaroslav@358
|
25 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
jaroslav@358
|
26 |
*
|
jaroslav@358
|
27 |
* Contributor(s):
|
jaroslav@358
|
28 |
*
|
jaroslav@358
|
29 |
* The Original Software is NetBeans. The Initial Developer of the Original
|
jaroslav@551
|
30 |
* Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
|
jaroslav@358
|
31 |
*
|
jaroslav@358
|
32 |
* If you wish your version of this file to be governed by only the CDDL
|
jaroslav@358
|
33 |
* or only the GPL Version 2, indicate your decision by adding
|
jaroslav@358
|
34 |
* "[Contributor] elects to include this software in this distribution
|
jaroslav@358
|
35 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
jaroslav@358
|
36 |
* single choice of license, a recipient has the option to distribute
|
jaroslav@358
|
37 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
jaroslav@358
|
38 |
* to extend the choice of license to its licensees as provided above.
|
jaroslav@358
|
39 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
jaroslav@358
|
40 |
* Version 2 license, then the option applies only if the new code is
|
jaroslav@358
|
41 |
* made subject to such option by the copyright holder.
|
jtulach@0
|
42 |
*/
|
jtulach@0
|
43 |
package net.java.html.json;
|
jtulach@0
|
44 |
|
jtulach@0
|
45 |
import java.lang.annotation.ElementType;
|
jtulach@0
|
46 |
import java.lang.annotation.Retention;
|
jtulach@0
|
47 |
import java.lang.annotation.RetentionPolicy;
|
jtulach@0
|
48 |
import java.lang.annotation.Target;
|
jtulach@0
|
49 |
|
jaroslav@32
|
50 |
/** Methods in class annotated by {@link Model} can be
|
jtulach@0
|
51 |
* annotated by this annotation to signal that they should be available
|
jaroslav@233
|
52 |
* as functions to users of the model classes. The method
|
jaroslav@233
|
53 |
* should be non-private, static and return <code>void</code>.
|
jaroslav@233
|
54 |
* It may take up to two arguments. One argument can be the type of
|
jaroslav@233
|
55 |
* the associated model class, the other argument can be of any type,
|
jaroslav@233
|
56 |
* but has to be named <code>data</code> - this one represents the
|
jaroslav@233
|
57 |
* actual data the function was invoked on. Example:
|
jaroslav@233
|
58 |
* <pre>
|
jaroslav@233
|
59 |
*
|
jaroslav@233
|
60 |
* {@link Model @Model}(className="Names", properties={
|
jaroslav@233
|
61 |
* {@link Property @Property}(name = "selectedName", type=String.class),
|
jaroslav@233
|
62 |
* {@link Property @Property}(name = "names", type=String.class, array = true)
|
jaroslav@233
|
63 |
* })
|
jaroslav@233
|
64 |
* static class NamesModel {
|
jaroslav@233
|
65 |
* {@link Function @Function} static void <b>nameSelected</b>(Names myModel, String data) {
|
jaroslav@233
|
66 |
* myModel.setSelectedName(data);
|
jaroslav@233
|
67 |
* }
|
jaroslav@233
|
68 |
*
|
jaroslav@233
|
69 |
* static void initialize() {
|
jaroslav@233
|
70 |
* Names pageModel = new Names("---", "Jarda", "Pepa", "Honza", "Jirka", "Tomáš");
|
jaroslav@233
|
71 |
* pageModel.applyBindings();
|
jaroslav@233
|
72 |
* }
|
jaroslav@233
|
73 |
* }
|
jaroslav@233
|
74 |
*
|
jaroslav@549
|
75 |
* // associated <a target="_blank" href="http://knockoutjs.com/">Knockout</a> HTML page:
|
jaroslav@233
|
76 |
*
|
jaroslav@549
|
77 |
* Selected name: <span data-bind="text: selectedName"></span>
|
jaroslav@233
|
78 |
* <ul data-bind="foreach: names">
|
jaroslav@549
|
79 |
* <li>
|
jaroslav@549
|
80 |
* <a data-bind="text: $data, click: $root.nameSelected" href="#"></a>
|
jaroslav@549
|
81 |
* </li>
|
jaroslav@549
|
82 |
* </ul>
|
jaroslav@233
|
83 |
* </pre>
|
jaroslav@233
|
84 |
* The above example would render:
|
jaroslav@233
|
85 |
* <hr>
|
jaroslav@233
|
86 |
* Selected name: <span>---</span>
|
jaroslav@233
|
87 |
* <ul>
|
jaroslav@233
|
88 |
* <li>Jarda</li>
|
jaroslav@233
|
89 |
* <li>Pepa</li>
|
jaroslav@233
|
90 |
* <li>Honza</li>
|
jaroslav@233
|
91 |
* <li>Jirka</li>
|
jaroslav@233
|
92 |
* <li>Tomáš</li>
|
jaroslav@233
|
93 |
* </ul>
|
jaroslav@233
|
94 |
* <hr>
|
jaroslav@233
|
95 |
* and after clicking on one of the names the <code>---</code> would be replaced
|
jaroslav@549
|
96 |
* by selected name.
|
jaroslav@549
|
97 |
* Try <a target="_blank" href="http://dew.apidesign.org/dew/#8848505">this sample on-line</a>!
|
jaroslav@233
|
98 |
*
|
jtulach@0
|
99 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jtulach@0
|
100 |
*/
|
jtulach@0
|
101 |
@Target(ElementType.METHOD)
|
jtulach@0
|
102 |
@Retention(RetentionPolicy.SOURCE)
|
jtulach@0
|
103 |
public @interface Function {
|
jtulach@0
|
104 |
}
|