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