src/main/javadoc/overview.html
author Toni Epple <maxnitribitt@netbeans.org>
Sat, 29 Aug 2015 01:43:59 +0200
changeset 964 6d931322368a
parent 951 5ce0aab2c03c
child 977 1be2ef455c55
permissions -rw-r--r--
#254779: Use -Dfirebug.lite=true to enable Firebug integration
jaroslav@550
     1
<!--
jaroslav@550
     2
jaroslav@550
     3
    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jaroslav@550
     4
jaroslav@551
     5
    Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
jaroslav@550
     6
jaroslav@550
     7
    Oracle and Java are registered trademarks of Oracle and/or its affiliates.
jaroslav@550
     8
    Other names may be trademarks of their respective owners.
jaroslav@550
     9
jaroslav@550
    10
    The contents of this file are subject to the terms of either the GNU
jaroslav@550
    11
    General Public License Version 2 only ("GPL") or the Common
jaroslav@550
    12
    Development and Distribution License("CDDL") (collectively, the
jaroslav@550
    13
    "License"). You may not use this file except in compliance with the
jaroslav@550
    14
    License. You can obtain a copy of the License at
jaroslav@550
    15
    http://www.netbeans.org/cddl-gplv2.html
jaroslav@550
    16
    or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jaroslav@550
    17
    specific language governing permissions and limitations under the
jaroslav@550
    18
    License.  When distributing the software, include this License Header
jaroslav@550
    19
    Notice in each file and include the License file at
jaroslav@550
    20
    nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
jaroslav@550
    21
    particular file as subject to the "Classpath" exception as provided
jaroslav@550
    22
    by Oracle in the GPL Version 2 section of the License file that
jaroslav@550
    23
    accompanied this code. If applicable, add the following below the
jaroslav@550
    24
    License Header, with the fields enclosed by brackets [] replaced by
jaroslav@550
    25
    your own identifying information:
jaroslav@550
    26
    "Portions Copyrighted [year] [name of copyright owner]"
jaroslav@550
    27
jaroslav@550
    28
    Contributor(s):
jaroslav@550
    29
jaroslav@550
    30
    The Original Software is NetBeans. The Initial Developer of the Original
jaroslav@551
    31
    Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
jaroslav@550
    32
jaroslav@550
    33
    If you wish your version of this file to be governed by only the CDDL
jaroslav@550
    34
    or only the GPL Version 2, indicate your decision by adding
jaroslav@550
    35
    "[Contributor] elects to include this software in this distribution
jaroslav@550
    36
    under the [CDDL or GPL Version 2] license." If you do not indicate a
jaroslav@550
    37
    single choice of license, a recipient has the option to distribute
jaroslav@550
    38
    your version of this file under either the CDDL, the GPL Version 2 or
jaroslav@550
    39
    to extend the choice of license to its licensees as provided above.
jaroslav@550
    40
    However, if you add GPL Version 2 code and therefore, elected the GPL
jaroslav@550
    41
    Version 2 license, then the option applies only if the new code is
jaroslav@550
    42
    made subject to such option by the copyright holder.
jaroslav@550
    43
jaroslav@550
    44
-->
jaroslav@541
    45
<!DOCTYPE html>
jaroslav@541
    46
<html>
jaroslav@541
    47
    <head>
jaroslav@541
    48
        <title>HTML for Java APIs</title>
jaroslav@541
    49
        <meta charset="UTF-8">
jaroslav@541
    50
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
jaroslav@541
    51
    </head>
jaroslav@541
    52
    <body>
jaroslav@541
    53
        <p>
jtulach@940
    54
         Use Java to write application logic; Use HTML5 to render the UI;
jaroslav@630
    55
         {@link net.java.html.json.Model Animate an HTML page from Java}
jtulach@668
    56
         (see <a target="_blank" href="http://dew.apidesign.org/dew/#7212206">Duke being rotated</a> by CSS);
jaroslav@543
    57
         Use {@link net.java.html.json.OnReceive REST} or
jaroslav@543
    58
         <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>;
jaroslav@543
    59
         interact with <a href="net/java/html/js/package-summary.html">JavaScript</a>;
jaroslav@543
    60
         Get the best of both worlds!
jtulach@940
    61
jtulach@940
    62
         The goal of these APIs is to use full featured Java runtime
jtulach@940
    63
         (like real <a href="http://wiki.apidesign.org/wiki/HotSpot">HotSpot VM</a>),
jtulach@940
    64
         but still rely on a very lightweight rendering technology
jtulach@940
    65
         (so it can potentially fit
jaroslav@541
    66
         <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a> and definitely
jtulach@940
    67
         to various types of phones). What can be more lightweight
jtulach@940
    68
         (from a browser perspective) than
jaroslav@541
    69
         <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>!?
jtulach@940
    70
         By default we use {@link net.java.html.boot.fx JavaFX's WebView}
jtulach@940
    71
         component to display the <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>.
jtulach@940
    72
         We eliminate the need to manipulate the DOM directly,
jtulach@940
    73
         there is a special {@link net.java.html.json Java to Knockout.js binding}.
jtulach@940
    74
         As a result the <a href="http://knockoutjs.com">HTML uses Knockout.js syntax</a>,
jaroslav@541
    75
         yet the application code can be written in Java.
jaroslav@541
    76
        </p>
jtulach@940
    77
jtulach@929
    78
        <h3>What's Been Improved in Version 1.2?</h3>
jtulach@940
    79
jtulach@940
    80
        One can control {@link net.java.html.json.OnReceive#headers() HTTP request headers}
jtulach@940
    81
        when connecting to server using the {@link net.java.html.json.OnReceive}
jtulach@951
    82
        annotation. It is possible to have
jtulach@951
    83
        {@link net.java.html.json.ComputedProperty#write() writable computed properties}.
maxnitribitt@964
    84
        There is an easy way to enable <a target="_blank" href="http://getfirebug.com/">Firebug</a> in
maxnitribitt@964
    85
        the JavaFX based Web View -
maxnitribitt@964
    86
        just run with <code>-Dfirebug.lite=true</code> as
maxnitribitt@964
    87
        <a target="_blank" href="https://www.youtube.com/watch?v=2rxwY-QJiLo">this video</a>
maxnitribitt@964
    88
        demonstrates.
jtulach@943
    89
        Bugfix of issues <a target="_blank" href='https://netbeans.org/bugzilla/show_bug.cgi?id=250503'>250503</a>,
jtulach@943
    90
        <a target="_blank" href='https://netbeans.org/bugzilla/show_bug.cgi?id=252987'>252987</a>.
jtulach@940
    91
jtulach@886
    92
        <h3>What's New in Version 1.1?</h3>
jtulach@940
    93
jtulach@886
    94
        <p>
jtulach@886
    95
            The content of a {@link net.java.html.BrwsrCtx context}
jtulach@886
    96
            can be selected by registering implementations under specific
jtulach@940
    97
            {@link org.netbeans.html.context.spi.Contexts.Id technology identifiers}
jtulach@940
    98
            and requesting them during
jtulach@940
    99
            {@link org.netbeans.html.context.spi.Contexts#newBuilder(java.lang.Object...) construction}
jtulach@886
   100
            of the context. <code>org.netbeans.html:ko4j</code> module's implementation
jtulach@886
   101
            offers <b>ko4j</b>, <b>xhr</b> and <b>websocket</b> identifiers
jtulach@940
   102
            for its registered services
jtulach@886
   103
            (e.g. {@link org.netbeans.html.json.spi.Technology},
jtulach@886
   104
            {@link org.netbeans.html.json.spi.Transfer} and
jtulach@886
   105
            {@link org.netbeans.html.json.spi.WSTransfer}).
jtulach@886
   106
            <code>org.netbeans.html:ko-ws-tyrus</code>
jtulach@940
   107
            module registers its
jtulach@940
   108
            {@link org.netbeans.html.json.spi.Transfer Java based JSON} and
jtulach@886
   109
            {@link org.netbeans.html.json.spi.WSTransfer WebSocket} implementations
jtulach@886
   110
            under the name <b>tyrus</b>.
jtulach@920
   111
        </p>
jtulach@920
   112
        <p>
jtulach@920
   113
            A particular DOM subtree
jtulach@920
   114
            that a <a target="_blank" href="http://knockoutjs.com">knockout.js</a> model gets
jtulach@940
   115
            applied to can be selected by using
jtulach@921
   116
            {@link net.java.html.json.Models#applyBindings(java.lang.Object,java.lang.String)
jtulach@920
   117
            Models.applyBindings(m, id)} with an id of an HTML element.
jtulach@940
   118
            There is new {@link net.java.html.json.Model#targetId()} attribute
jtulach@940
   119
            which controls behavior of the generated <code>applyBindings</code> method.
jtulach@920
   120
            If <em>specified and non-empty</em>, then the generated method
jtulach@920
   121
            will call {@link net.java.html.json.Models#applyBindings(java.lang.Object,java.lang.String)}
jtulach@920
   122
            with <code>this</code> and the provided {@link net.java.html.json.Model#targetId() target id}.
jtulach@920
   123
            If <em>specified, but left empty</em>, then the generated method
jtulach@920
   124
            calls {@link net.java.html.json.Models#applyBindings(java.lang.Object)}.
jtulach@920
   125
            <em>If unspecified</em>, the method will <b>not</b> be generated at all
jtulach@920
   126
            (a change with respect to older versions). However one can
jtulach@920
   127
            still use {@link net.java.html.json.Models#applyBindings(java.lang.Object)}
jtulach@920
   128
            or {@link net.java.html.json.Models#applyBindings(java.lang.Object,java.lang.String)}
jtulach@920
   129
            to perform the association of any model with the page element.
jtulach@920
   130
        </ul>
jtulach@920
   131
        <p>
jtulach@870
   132
            Memory model when using Knockout bindings has been improved
jtulach@870
   133
            (required additions of two new methods:
jtulach@870
   134
            {@link org.netbeans.html.json.spi.PropertyBinding#weak()} and
jtulach@870
   135
            {@link org.netbeans.html.json.spi.FunctionBinding#weak()}) and
jtulach@870
   136
            now the Java {@link net.java.html.json.Model models} can garbage collect,
jtulach@940
   137
            when no longer used. Library writers that use
jtulach@940
   138
            {@link net.java.html.js.JavaScriptBody} annotation can also
jtulach@903
   139
            control garbage collection behavior of method arguments by
jtulach@903
   140
            setting {@link net.java.html.js.JavaScriptBody#keepAlive() keepAlive=false}
jtulach@903
   141
            attribute.
jtulach@886
   142
        </p>
jtulach@940
   143
jtulach@832
   144
        <h3>What's New in Version 1.0?</h3>
jtulach@940
   145
jtulach@832
   146
        <p>
jtulach@832
   147
            {@link net.java.html.json.Property#array() Array properties} are now
jtulach@832
   148
            mutable from the <a href="http://knockoutjs.com">knockout.js</a>
jtulach@838
   149
            point of view (required {@link org.netbeans.html.json.spi.Proto.Type#replaceValue one SPI change}).
jtulach@834
   150
            The page lookup mechanism can use {@link net.java.html.boot.BrowserBuilder#locale(java.util.Locale) locale}
jtulach@834
   151
            to load localized a page with appropriate suffix.
jtulach@841
   152
            All SPI were moved under the NetBeans namespace - e.g.
jtulach@841
   153
            {@link org.netbeans.html.boot.spi},
jtulach@841
   154
            {@link org.netbeans.html.context.spi},
jtulach@841
   155
            {@link org.netbeans.html.json.spi},
jtulach@841
   156
            {@link org.netbeans.html.sound.spi}, and also
jtulach@852
   157
            {@link org.netbeans.html.json.tck}. Methods annotated
jtulach@852
   158
            with {@link net.java.html.js.JavaScriptBody} annotation and
jtulach@852
   159
            without fallback Java code now throw {@link java.lang.IllegalStateException}
jtulach@852
   160
            with a message suggesting to switch to proper
jtulach@852
   161
            {@link net.java.html.BrwsrCtx#execute browser context} to
jtulach@852
   162
            prevent endless debugging when one forgets to do so.
jtulach@832
   163
        </p>
jtulach@940
   164
jtulach@887
   165
        <p>
jtulach@940
   166
        What's new in older versions? Click the
jtulach@940
   167
        <a href="#" onclick="return showHistoric(true)">link</a>
jtulach@940
   168
        to view even more
jtulach@887
   169
        <a href="#" onclick="return showHistoric(true)">historic changes</a> below:
jtulach@887
   170
        </p>
jtulach@940
   171
jtulach@887
   172
        <a name="historic.changes"></a>
jtulach@887
   173
        <div id="historic.changes">
jtulach@887
   174
            <script>
jtulach@887
   175
            function showHistoric(show) {
jtulach@887
   176
                var e = document.getElementById("historic.changes");
jtulach@887
   177
                if (show) {
jtulach@887
   178
                    e.style.display="block";
jtulach@887
   179
                } else {
jtulach@887
   180
                    e.style.display="none";
jtulach@887
   181
                }
jtulach@887
   182
                return false;
jtulach@887
   183
            }
jtulach@887
   184
            showHistoric(false);
jtulach@887
   185
            </script>
jtulach@940
   186
jtulach@771
   187
        <h3>What's New in Version 0.9?</h3>
jtulach@940
   188
jtulach@771
   189
        <p>
jtulach@771
   190
            System can run in {@link net.java.html.boot.BrowserBuilder#classloader(java.lang.ClassLoader) Felix OSGi container} (originally only Equinox).
jtulach@788
   191
            {@link net.java.html.json.ComputedProperty Derived properties}
jtulach@788
   192
            now deeply check changes in other {@link net.java.html.json.Model model
jtulach@788
   193
            classes} they depend on and recompute their values accordingly.
jtulach@810
   194
            <a target="_blank" href="http://knockoutjs.com">Knockout.js</a> library has been updated
jtulach@810
   195
            to version 3.2.0.
jtulach@771
   196
        </p>
jtulach@940
   197
jtulach@771
   198
        <h3>What's New in 0.8.x Versions?</h3>
jtulach@940
   199
jaroslav@720
   200
        <p>
jaroslav@720
   201
            Setters or array properties on classes generated by {@link net.java.html.json.Model}
jtulach@838
   202
            annotation can be accessed from any thread. {@link org.netbeans.html.sound.spi.AudioEnvironment}
jtulach@747
   203
            can be registered into {@link net.java.html.BrwsrCtx}. There is
jtulach@747
   204
            a {@link net.java.html.json.Models#parse(net.java.html.BrwsrCtx, java.lang.Class, java.io.InputStream, java.util.Collection)  method}
jtulach@940
   205
            to parse a JSON array and convert it into
jtulach@747
   206
            {@link net.java.html.json.Model model classes}.
jtulach@940
   207
            Improved behavior of <code>enum</code> values in
jtulach@758
   208
            {@link net.java.html.json.Model knockout bindings}.
jaroslav@720
   209
        </p>
jtulach@940
   210
jtulach@702
   211
        <p>
jtulach@940
   212
            Few bugfixes for better portability.
jtulach@702
   213
            New API for {@link net.java.html.boot.script.Scripts headless execution}
jtulach@703
   214
            on top of <em>Nashorn</em> - does not run <em>knockout for Java</em>
jtulach@940
   215
            fully yet
jtulach@702
   216
            (reported as <a href="https://bugs.openjdk.java.net/browse/JDK-8046013">JDK-8046013</a>),
jtulach@940
   217
            however even in current state it is quite
jtulach@703
   218
            {@link net.java.html.boot.script.Scripts useful for testing}
jtulach@940
   219
            of
jtulach@703
   220
            {@link net.java.html.js Java/JavaScript interactions}.
jtulach@702
   221
        </p>
jtulach@940
   222
jtulach@654
   223
        <p>
jtulach@656
   224
            {@link net.java.html.boot.fx.FXBrowsers} has been extended
jtulach@656
   225
            with new helper methods to make it easier to use HTML+Java
jtulach@656
   226
            API in existing JavaFX applications.
jtulach@656
   227
            The annotation processor is made
jtulach@654
   228
            more robust with respect to errors in callback syntax of
jtulach@654
   229
            {@link net.java.html.js.JavaScriptBody} body parameter.
jtulach@654
   230
            Javadoc of {@link net.java.html.BrwsrCtx#execute} method
jtulach@654
   231
            has been improved based on a failure of its usability study.
jtulach@654
   232
            There can be additional parameters to methods annotated by
jtulach@654
   233
            {@link net.java.html.json.OnReceive} that allows one to
jtulach@654
   234
            pass state when a JSON call is made and use it when it finishes.
jtulach@654
   235
            The mechanism of discovery of sibling HTML page has been
jtulach@654
   236
            extended to work on systems that don't support
jtulach@654
   237
            {@link java.lang.Class#getProtectionDomain}.
jtulach@654
   238
        </p>
jtulach@940
   239
jaroslav@617
   240
        <p>
jtulach@650
   241
            The first argument of method annotated by
jtulach@650
   242
            {@link net.java.html.json.OnReceive} annotation has to
jtulach@650
   243
            be the associated {@link net.java.html.json.Model model class}.
jtulach@650
   244
        </p>
jtulach@940
   245
jtulach@650
   246
        <p>
jtulach@647
   247
            {@link net.java.html.json.OnReceive} annotation now accepts
jtulach@647
   248
            {@link java.util.List} of data values as second argument
jtulach@647
   249
            (previously required an array).
jtulach@647
   250
        </p>
jtulach@940
   251
jtulach@940
   252
jtulach@887
   253
        <h3>What's New in 0.7.x Versions?</h3>
jtulach@940
   254
jtulach@647
   255
        <p>
jaroslav@617
   256
            {@link net.java.html.js.JavaScriptBody} annotation has new attribute
jaroslav@617
   257
            {@link net.java.html.js.JavaScriptBody#wait4js()} which allows
jaroslav@617
   258
            asynchronous execution. Libraries using
jaroslav@617
   259
            {@link net.java.html.js.JavaScriptBody} are urged to use this
jaroslav@617
   260
            new attribute as much as possible, as it can speed up execution
jaroslav@617
   261
            in certain environments.
jaroslav@617
   262
        </p>
jtulach@940
   263
jaroslav@617
   264
        <p>
jaroslav@617
   265
            Use {@link net.java.html.BrwsrCtx#execute(java.lang.Runnable)} in
jaroslav@617
   266
            multi-threaded environment to execute your code on the browser thread.
jtulach@940
   267
            See example
jaroslav@617
   268
            {@link net.java.html.BrwsrCtx#execute(java.lang.Runnable) using Java timer}.
jaroslav@617
   269
        </p>
jtulach@887
   270
        </div>
jtulach@940
   271
jaroslav@541
   272
        <h3>Interesting Entry Points</h3>
jtulach@940
   273
jaroslav@541
   274
        <p>Learn how to {@link net.java.html.json.Model animate an HTML page from Java}
jaroslav@541
   275
            without referencing single HTML element from the Java code.
jaroslav@541
   276
        </p>
jaroslav@541
   277
        <p>Use {@link net.java.html.json.OnReceive JSON} to communicate
jaroslav@541
   278
            with REST based server API.
jaroslav@541
   279
        </p>
jaroslav@541
   280
        <p>Use <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>
jaroslav@541
   281
            and JSON.
jaroslav@541
   282
        </p>
jaroslav@541
   283
        <p>Call JavaScript methods from Java and vice versa, via
jaroslav@541
   284
            <a href="net/java/html/js/package-summary.html">JavaScriptBody</a>.
jaroslav@541
   285
        </p>
jaroslav@541
   286
jaroslav@541
   287
        <h3>Getting Started</h3>
jaroslav@541
   288
jtulach@940
   289
        There are <a href="http://wiki.apidesign.org/wiki/DukeScriptInNetBeans">many ways</a>
jtulach@940
   290
        to start developing
jtulach@940
   291
        <a href="http://html.java.net">Html for Java</a> application.
jaroslav@541
   292
        However to be sure one chooses the most recent setup, it is recommended
jtulach@940
   293
        to switch to good old command line and use a
jaroslav@541
   294
        <a href="http://wiki.apidesign.org/wiki/Knockout4Java">Maven archetype</a>
jtulach@940
   295
        associated with every version of this project. Make sure at least
jaroslav@610
   296
        <em>JDK7</em> is your installed Java and type:
jtulach@940
   297
        <pre>
jaroslav@541
   298
$ mvn archetype:generate \
jaroslav@541
   299
 -DarchetypeGroupId=org.apidesign.html \
jaroslav@541
   300
 -DarchetypeArtifactId=knockout4j-archetype \
jtulach@759
   301
 -DarchetypeVersion=0.8 <em># or newer version, if available</em>
jaroslav@541
   302
        </pre>
jtulach@940
   303
        Answer few questions (for example choose myfirstbrwsrpage as artifactId)
jaroslav@611
   304
        and then you can:
jaroslav@541
   305
        <pre>
jaroslav@541
   306
$ cd myfirstbrwsrpage
jaroslav@541
   307
$ mvn process-classes exec:java
jaroslav@541
   308
        </pre>
jtulach@940
   309
        In a few seconds (or minutes if
jaroslav@541
   310
        <a href="http://wiki.apidesign.org/wiki/Maven">Maven</a>
jtulach@940
   311
        decides to download the whole Internet of dependencies) you should
jtulach@940
   312
        see a sample Hello World application rendered in a
jaroslav@611
   313
        <a href="http://wiki.apidesign.org/wiki/JavaFX">JavaFX</a>
jaroslav@611
   314
        web view component (that of course requires your JDK to come
jtulach@940
   315
        with <a href="http://wiki.apidesign.org/wiki/JavaFX">JavaFX</a>;
jtulach@940
   316
        <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK7
jtulach@940
   317
            and JDK8 from Oracle</a> contain everything that is needed).
jtulach@940
   318
        The generated application is built around one
jaroslav@611
   319
        Java source (uses the {@link net.java.html.json.Model} annotation to
jaroslav@611
   320
        auto-generate another <code>Data.java</code> class during compilation)
jaroslav@611
   321
        and one HTML file (uses the <a href="http://knockoutjs.com">Knockout</a>
jtulach@940
   322
        syntax to <code>data-bind</code> the HTML elements to the
jaroslav@611
   323
        generated <code>Data</code> model):
jaroslav@541
   324
        <pre>
jaroslav@541
   325
$ ls src/main/java/**/DataModel.java
jaroslav@541
   326
$ ls src/main/webapp/pages/index.html
jaroslav@541
   327
        </pre>
jtulach@940
   328
        That is all you need to get started. Play with the sources,
jaroslav@611
   329
        modify them and enjoy
jaroslav@541
   330
        <a href="http://html.java.net">Html for Java</a>!
jtulach@940
   331
jaroslav@614
   332
        <h2>IDE Support</h2>
jtulach@940
   333
jaroslav@614
   334
        <p>
jaroslav@614
   335
            This API is part of <a target="_blank"
jaroslav@614
   336
            href="http://netbeans.org">NetBeans.org</a> project and as such
jaroslav@614
   337
            it works naturally with the <a target="_blank"
jaroslav@614
   338
            href="https://netbeans.org/features/index.html">NetBeans IDE</a>.
jaroslav@614
   339
            On the other hand, the API is using nothing NetBeans specific,
jaroslav@614
   340
            it builds on standard Java6 APIs and as such it shall work fine
jaroslav@614
   341
            in any IDE.
jaroslav@614
   342
        </p>
jtulach@940
   343
jaroslav@614
   344
        <p>
jtulach@940
   345
            A lot of work is done by
jaroslav@614
   346
            <a href="http://wiki.apidesign.org/wiki/AnnotationProcessor">
jaroslav@614
   347
            annotation processors</a>
jaroslav@614
   348
            that generate various boiler plate code during compilation. This
jaroslav@614
   349
            is a standard part of Java since JDK6, but for example Eclipse
jaroslav@614
   350
            is known not to deal with processors well and developers using
jaroslav@614
   351
            it need to be careful. IntelliJ users hasn't reported any issues
jtulach@940
   352
            and of course, NetBeans IDE support for
jaroslav@614
   353
            <a href="http://wiki.apidesign.org/wiki/AnnotationProcessor">processors</a>
jaroslav@614
   354
            is outstanding.
jaroslav@614
   355
        </p>
jtulach@940
   356
jaroslav@614
   357
        <p>
jaroslav@614
   358
            When using {@link net.java.html.js.JavaScriptBody} annotation, it is
jaroslav@614
   359
            useful to do a bit of post processing of classes. There is a
jtulach@940
   360
            <a href="http://wiki.apidesign.org/wiki/Maven">Maven</a>
jaroslav@614
   361
            plugin for that.
jtulach@940
   362
            NetBeans IDE will invoke it when doing a build. Other IDEs may
jtulach@940
   363
            need some hint to do so.
jaroslav@614
   364
            Anyway: If one does not see all (generated) sources or is getting
jtulach@940
   365
            {@link java.lang.LinkageError}s when executing the application,
jaroslav@614
   366
            switch to command line and do clean build
jaroslav@614
   367
            from there:
jaroslav@614
   368
        </p>
jaroslav@614
   369
        <pre>$ mvn clean install</pre>
jaroslav@614
   370
        <p>
jaroslav@614
   371
            If that succeeds, your IDE of choice will hopefully
jtulach@940
   372
            pick the generated sources up and present the result of the build
jtulach@940
   373
            properly. If not,
jtulach@940
   374
            <a href="https://netbeans.org/downloads/">download NetBeans</a>,
jtulach@940
   375
            you will be pleasantly
jtulach@940
   376
            surprised - for example with our excellent
jtulach@940
   377
            <a href="net/java/html/js/package-summary.html#debugging">Java/JavaScript
jaroslav@614
   378
            debugging</a> support.
jaroslav@614
   379
        </p>
jtulach@940
   380
jaroslav@615
   381
        <a name="deploy">
jaroslav@615
   382
        <h2>Deploy Your Application</h2>
jaroslav@615
   383
        </a>
jtulach@940
   384
jaroslav@615
   385
        <p>
jaroslav@615
   386
        It is not goal of this documentation to list all possible ways
jtulach@940
   387
        to package and deploy applications which use this API. However it is
jaroslav@615
   388
        important for new comers to see the benefits of using the
jaroslav@615
   389
        <a href="http://html.java.net">HTML for Java</a> API and as such
jtulach@940
   390
        let's list at least few bundling options, known to work at the time of writing
jaroslav@615
   391
        this documentation.
jaroslav@615
   392
        </p>
jtulach@940
   393
jaroslav@615
   394
        <p>
jaroslav@615
   395
        First of all, this is a <em>client technology</em>. You write client applications
jaroslav@615
   396
        with it which may, but need not connect to a server. You don't need
jtulach@940
   397
        Tomcat or WebLogic to deploy
jaroslav@615
   398
        <a href="http://html.java.net">HTML for Java</a> applications.
jaroslav@615
   399
        </p>
jtulach@940
   400
jaroslav@615
   401
        <p>
jaroslav@615
   402
            <img src='resources/javafx_logo.jpg' width="64"
jaroslav@615
   403
                 height="64" align="left"/>
jaroslav@615
   404
            The sample project generated by
jaroslav@615
   405
            <code>org.apidesign.html knockout4j-archetype</code> is configured
jaroslav@615
   406
            to use <a href="http://wiki.apidesign.org/wiki/JavaFX">JavaFX</a>
jtulach@940
   407
            as the rendering technology. This setup is primarily suitable for
jaroslav@615
   408
            development - it needs no special packaging, starts quickly and
jtulach@940
   409
            allows you to use classical HotSpot VM debuggers. A final
jaroslav@615
   410
            artifact from the build is also a ZIP file which you can use
jaroslav@615
   411
            and distribute to your users. Good for desktop applications.
jaroslav@615
   412
        </p>
jtulach@940
   413
jaroslav@615
   414
        <p>
jaroslav@615
   415
            <img src='resources/netbeans_logo.jpg' width="64"
jaroslav@615
   416
                 height="64" align="right"/>
jaroslav@615
   417
            <img src='resources/eclipse_logo.png' width="64"
jaroslav@615
   418
                 height="64" align="right"/>
jaroslav@615
   419
            All the <a href="http://html.java.net">HTML for Java</a> libraries
jtulach@638
   420
            are packaged as <a href="http://wiki.apidesign.org/wiki/OSGi">OSGi</a>
jaroslav@615
   421
            bundles and as such they can easily be run in NetBeans as well as
jtulach@940
   422
            in Eclipse. As a result one can use
jaroslav@615
   423
            <a href="http://wiki.apidesign.org/wiki/OSGi">OSGi</a>
jtulach@940
   424
            and have a common module system for both platforms. In addition to that
jtulach@638
   425
            one can render using
jaroslav@615
   426
            HTML and have a common UI in both platforms. In such case
jaroslav@615
   427
            your application would be packaged as a set of
jaroslav@615
   428
            <a href="http://wiki.apidesign.org/wiki/OSGi">OSGi</a> bundles.
jtulach@940
   429
            Read
jaroslav@615
   430
            <a href="http://wiki.apidesign.org/wiki/HTML">more</a>...
jaroslav@615
   431
        </p>
jtulach@940
   432
jaroslav@615
   433
        <p>
jaroslav@615
   434
            <img src='resources/chrome_logo.png' width="64"
jaroslav@615
   435
                 height="64" align="left"/>
jaroslav@615
   436
            <img src='resources/safari_logo.png' width="64"
jaroslav@615
   437
                 height="64" align="left"/>
jaroslav@615
   438
            <img src='resources/ie_logo.png' width="64"
jaroslav@615
   439
                 height="64" align="left"/>
jaroslav@615
   440
            <img src='resources/firefox_logo.png' width="64"
jaroslav@615
   441
                 height="64" align="left"/>
jtulach@940
   442
jaroslav@615
   443
            There is more and more attempts to execute Java bytecode
jtulach@638
   444
            in a browser, without any special Java plugin installed.
jaroslav@615
   445
            The <a href="http://html.java.net">HTML for Java</a> is
jaroslav@615
   446
            carefully designed to produce lightweight, well performing
jaroslav@615
   447
            applications even on such restricted environments. It uses
jaroslav@615
   448
            no reflection calls and that allows to statically pre-compile
jaroslav@615
   449
            the applications into JavaScript. One of such environments
jtulach@940
   450
            is called <a href="http://wiki.apidesign.org/wiki/Bck2Brwsr">Bck2Brwsr</a>,
jtulach@638
   451
            another <a href="http://wiki.apidesign.org/wiki/TeaVM">TeaVM</a>. Both support the
jtulach@940
   452
            {@link net.java.html.js.JavaScriptBody} annotation. Read
jaroslav@615
   453
            <a href="http://wiki.apidesign.org/wiki/Bck2BrwsrViaCLI">more</a> or play
jtulach@940
   454
            a minesweeper game packaged for your browser
jaroslav@616
   455
            (of course <a target="_blank"
jaroslav@616
   456
                href="http://source.apidesign.org/hg/html~demo/file/ea79b73d590a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java">
jaroslav@616
   457
                written</a> in Java):
jaroslav@615
   458
        </p>
jtulach@940
   459
jaroslav@616
   460
        <script type="text/html" id="field">
jaroslav@616
   461
            <table class="field">
jaroslav@616
   462
                <tbody>
jaroslav@616
   463
                    <!-- ko foreach: rows -->
jaroslav@616
   464
                    <tr>
jaroslav@616
   465
                        <!-- ko foreach: columns -->
jaroslav@616
   466
                        <td data-bind="css: style, click: $parents[1].click" >
jaroslav@616
   467
                            <div data-bind='html: html'></div>
jaroslav@616
   468
                        </td>
jaroslav@616
   469
                        <!-- /ko -->
jaroslav@616
   470
                    </tr>
jaroslav@616
   471
                    <!-- /ko -->
jaroslav@616
   472
                </tbody>
jaroslav@616
   473
            </table>
jaroslav@616
   474
        </script>
jaroslav@616
   475
jaroslav@616
   476
        <div data-bind="template: { name : 'field', if: fieldShowing }"></div>
jaroslav@616
   477
jaroslav@616
   478
        <!-- boot bck2brwsr -->
jaroslav@616
   479
        <script type="text/javascript" src="resources/teavm.js"></script>
jaroslav@616
   480
        <script>
jaroslav@616
   481
            var vm = new VM();
jaroslav@616
   482
            vm.loadClass('org.apidesign.demo.minesweeper.MainBrwsr');
jaroslav@616
   483
        </script>
jaroslav@616
   484
jaroslav@615
   485
        <p>
jtulach@654
   486
            <img src='resources/ios_logo.jpg' width="64"
jtulach@654
   487
                 height="64" align="right"/>
jaroslav@615
   488
            <img src='resources/android_logo.jpg' width="64"
jaroslav@615
   489
                 height="64" align="right"/>
jtulach@940
   490
jtulach@940
   491
            Now when we have seen that the
jtulach@940
   492
            <a href="http://html.java.net">HTML for Java</a> applications
jaroslav@615
   493
            can run on any modern browser, we can ask whether they can also
jtulach@940
   494
            fit into a phone!? Yes, they can and especially to phones
jaroslav@615
   495
            that can execute Java code already! Just by changing your
jaroslav@615
   496
            packaging you can create an APK file and deploy it to your
jtulach@940
   497
            Android phone.
jtulach@624
   498
            Read <a target="_blank" href="http://wiki.apidesign.org/wiki/DlvkBrwsr">more</a>...
jtulach@654
   499
            In case you'd like your application to reach out to second biggest
jtulach@940
   500
            group of smartphone users, don't despair: It
jtulach@654
   501
            seems the set of devices that can execute
jtulach@940
   502
            <a href="http://html.java.net">HTML for Java</a> applications
jtulach@940
   503
            has been extended to <em>iPads</em> and <em>iPhones</em>. Get the
jtulach@654
   504
            <a target="_blank" href="http://wiki.apidesign.org/wiki/IBrwsr">details here</a>
jtulach@654
   505
            and deploy everywhere!
jaroslav@615
   506
        </p>
jaroslav@615
   507
        <p>
jtulach@940
   508
            Convinced it makes sense to use
jaroslav@615
   509
            <a href="http://html.java.net">HTML for Java</a>
jtulach@940
   510
            APIs for writing applications that are
jaroslav@615
   511
            <em>written once, displayed anywhere</em>? Or do you have an
jaroslav@615
   512
            environment which is not supported? In such case you can bring
jaroslav@615
   513
            <a href="http://html.java.net">HTML for Java</a>
jaroslav@615
   514
            to your environment yourself. Just implement your own
jtulach@838
   515
            {@link org.netbeans.html.boot.spi.Fn.Presenter}!
jaroslav@615
   516
        </p>
jtulach@940
   517
jaroslav@607
   518
        <h2>Other Resources</h2>
jtulach@940
   519
jaroslav@607
   520
        <img src="net/java/html/json/doc-files/DukeHTML.png" width="256" height="184" alt="Duke and HTML5. Together at last!" align="right"/>
jtulach@940
   521
jaroslav@607
   522
        The javadoc for latest and previous versions is also available
jaroslav@607
   523
        online:
jaroslav@607
   524
        <ul>
jaroslav@607
   525
            <li>Current <a target="_blank" href="http://bits.netbeans.org/html+java/dev/">development</a> version
jtulach@940
   526
            <li>Version <a target="_blank" href="http://bits.netbeans.org/html+java/1.1">1.1</a>
jtulach@891
   527
            <li>Version <a target="_blank" href="http://bits.netbeans.org/html+java/1.0">1.0</a>
jtulach@940
   528
            <li>Version <a target="_blank" href="http://bits.netbeans.org/html+java/0.9">0.9</a>
jtulach@891
   529
                and historic ones (<a target="_blank" href="http://bits.netbeans.org/html+java/0.8.3">0.8.3</a>,
jtulach@940
   530
                <a target="_blank" href="http://bits.netbeans.org/html+java/0.8.2">0.8.2</a>,
jtulach@891
   531
                <a target="_blank" href="http://bits.netbeans.org/html+java/0.8.1">0.8.1</a>,
jtulach@891
   532
                <a target="_blank" href="http://bits.netbeans.org/html+java/0.8">0.8</a>, and
jtulach@891
   533
                <a target="_blank" href="http://bits.netbeans.org/html+java/0.7.5">0.7.5</a>)
jtulach@891
   534
            </li>
jaroslav@607
   535
        </ul>
jtulach@940
   536
jaroslav@616
   537
<style type="text/css">
jaroslav@616
   538
table.field td {
jaroslav@616
   539
    padding: 4px;
jaroslav@616
   540
    width: 18px;
jaroslav@616
   541
    height: 18px;
jaroslav@616
   542
    font-size: 1.5em;
jaroslav@616
   543
    border: 1px solid black;
jaroslav@616
   544
}
jaroslav@616
   545
table.field td.UNKNOWN {
jaroslav@616
   546
    background-color: #D6E4E1;
jaroslav@616
   547
    cursor: pointer;
jaroslav@616
   548
}
jaroslav@616
   549
table.field td.EXPLOSION {
jaroslav@616
   550
    background-color: #A31E39;
jaroslav@616
   551
}
jaroslav@616
   552
table.field td.DISCOVERED {
jaroslav@616
   553
    background-color: #9DB2B1;
jaroslav@616
   554
}
jtulach@940
   555
</style>
jaroslav@541
   556
    </body>
jaroslav@541
   557
</html>