json/src/main/java/net/java/html/json/package.html
author Jaroslav Tulach <jaroslav.tulach@netbeans.org>
Mon, 16 Dec 2013 17:39:56 +0100
changeset 365 5c93ad8c7a15
parent 358 80702021b851
child 422 b0e1a10c2f42
permissions -rw-r--r--
The work on this project started in 2013
     1 <!--
     2 
     3     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4 
     5     Copyright 2013-2013 Oracle and/or its affiliates. All rights reserved.
     6 
     7     Oracle and Java are registered trademarks of Oracle and/or its affiliates.
     8     Other names may be trademarks of their respective owners.
     9 
    10     The contents of this file are subject to the terms of either the GNU
    11     General Public License Version 2 only ("GPL") or the Common
    12     Development and Distribution License("CDDL") (collectively, the
    13     "License"). You may not use this file except in compliance with the
    14     License. You can obtain a copy of the License at
    15     http://www.netbeans.org/cddl-gplv2.html
    16     or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    17     specific language governing permissions and limitations under the
    18     License.  When distributing the software, include this License Header
    19     Notice in each file and include the License file at
    20     nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    21     particular file as subject to the "Classpath" exception as provided
    22     by Oracle in the GPL Version 2 section of the License file that
    23     accompanied this code. If applicable, add the following below the
    24     License Header, with the fields enclosed by brackets [] replaced by
    25     your own identifying information:
    26     "Portions Copyrighted [year] [name of copyright owner]"
    27 
    28     Contributor(s):
    29 
    30     The Original Software is NetBeans. The Initial Developer of the Original
    31     Software is Oracle. Portions Copyright 2013-2013 Oracle. All Rights Reserved.
    32 
    33     If you wish your version of this file to be governed by only the CDDL
    34     or only the GPL Version 2, indicate your decision by adding
    35     "[Contributor] elects to include this software in this distribution
    36     under the [CDDL or GPL Version 2] license." If you do not indicate a
    37     single choice of license, a recipient has the option to distribute
    38     your version of this file under either the CDDL, the GPL Version 2 or
    39     to extend the choice of license to its licensees as provided above.
    40     However, if you add GPL Version 2 code and therefore, elected the GPL
    41     Version 2 license, then the option applies only if the new code is
    42     made subject to such option by the copyright holder.
    43 
    44 -->
    45 <body>
    46     
    47     <p>
    48     This API allows you to write your application logic in Java and 
    49     present it using modern HTML rendering technologies like 
    50     <a href="http://knockoutjs.com">Knockout</a>
    51     <img src="doc-files/html4j.png">.
    52     </p>
    53     <p>
    54     Use <a href="Model.html">@Model</a> annotation to define one or more
    55     model classes with <a href="Property.html">properties</a>. Don't waste
    56     time writing setters or getters - they will be generated for you. 
    57     Just instantiate your classes and use them!
    58     </p>
    59     <p>
    60     The class generator does not stop with getters and setters -- internally
    61     it generates bindings for various HTML technologies. Just include appropriate
    62     technology implementation on classpath of your application and your model
    63     class(es) will automatically be bound to your HTML elements (after calling
    64     <code>applyBindings()</code> on your model).
    65     </p>
    66     <p>
    67     You don't have bother with JavaScript. All your application logic is in
    68     Java. The necessary JavaScript needed for the HTML bindings remains hidden
    69     as an implementation detail of communication between the generated model
    70     class(es) and appropriate technology bridge (like artifact with id <code>ko-fx</code>
    71     and group id <code>org.apidesign.html</code>).
    72     </p>
    73     <p>
    74     The model classes can be used for JSON based server communication. Just
    75     use <a href="OnReceive.html">@OnReceive</a> annotation to define a communication
    76     point in the model class. Please note, that the model classes can easily
    77     be used on server as well - the same code can run
    78     in your browser as well as on your server. Just add following to your <em>pom.xml</em>
    79     to use your classes generated by <a href="Model.html">@Model</a> annotation
    80     as <a href="http://jersey.java.net" target="new">Jersey</a> entities:
    81     </p>
    82     <pre>
    83 &lt;dependency&gt;
    84   &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
    85   &lt;artifactId&gt;html-json&lt;/artifactId&gt;
    86   &lt;version&gt;2.1&lt;/version&gt;
    87   &lt;scope&gt;runtime&lt;/scope&gt;
    88 &lt;/dependency&gt;
    89     </pre>
    90     <p>
    91     Behavior of model classes can be enriched by using 
    92     <a href="ComputedProperty.html">@ComputedProperty</a> annotation (to
    93     define <em>derived</em> properties) and by 
    94     <a href="Function.html">@Function</a> annotation to define handlers
    95     to be invoked from the HTML elements.
    96     </p>
    97     <script type="text/javascript">
    98         var arr = document.getElementsByTagName("img");
    99         if (arr.length === 2) {
   100             arr[0].style.visibility = 'hidden';
   101             arr[0].height = 0;
   102         }
   103     </script>
   104 </body>