Knockout4Java
From APIDesign
(→Knockout for Java) |
|||
(17 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
- | [[Knockout.js]] is powerful and attractive [[JavaScript]] library. It is lightweight and does its job (e.g. binding between a model and an [[HTML]] page) so well, that I decided to use it in my [[Bck2Brwsr]] and [[FXBrwsr]] projects and bind it together with [[JSON4Brwsr]] [[API]]s. | + | [[Knockout4Java]] is one of the subprojects of [[Apache]] [[NetBeans]]. It builds on [[Knockout.js]], which is a powerful and attractive [[JavaScript]] library. It is lightweight and does its job (e.g. binding between a model and an [[HTML]] page) so well, that I decided to use it in my [[Bck2Brwsr]] and [[FXBrwsr]] projects and bind it together with [[JSON4Brwsr]] [[API]]s. |
== Knockout for [[Java]] == | == Knockout for [[Java]] == | ||
- | Are you coming from a [[Java]] camp, yet interested in rendering via [[HTML]]? Well, then you | + | Are you coming from a [[Java]] camp, yet interested in rendering via [[HTML]]? Well, then you can either use [[DukeScriptInNetBeans]] or stay on command and be just three steps (in case you have [[Maven]] and [[JDK]]7 installed) away from [https://dukescript.com/update/2015/02/05/New-Version-of-Dukescript.html reaching a nirvana]. Just type: |
<source lang="bash"> | <source lang="bash"> | ||
$ mvn archetype:generate \ | $ mvn archetype:generate \ | ||
- | + | -DarchetypeGroupId=com.dukescript.archetype \ | |
- | + | -DarchetypeArtifactId=knockout4j-archetype \ | |
- | + | -DarchetypeVersion=0.16 | |
</source> | </source> | ||
Line 16: | Line 16: | ||
<source lang="bash"> | <source lang="bash"> | ||
$ cd myfirstbrwsrpage | $ cd myfirstbrwsrpage | ||
- | $ mvn process-classes | + | $ mvn package |
+ | $ mvn -f client process-classes exec:exec | ||
</source> | </source> | ||
- | In a few seconds (or minutes if [[Maven]] decides to download the whole Internet of dependencies) you should see a sample | + | In a few seconds (or minutes if [[Maven]] decides to download the whole Internet of dependencies) you should see a sample ''Hello World'' application. It is basically composed from one [[Java]] and one [[HTML]] file: |
<source lang="bash"> | <source lang="bash"> | ||
- | $ ls | + | $ ls client/src/main/java/**/DataModel.java |
- | $ ls | + | $ ls client/src/main/webapp/pages/index.html |
- | + | ||
</source> | </source> | ||
- | Play with them, modify them. Of course, if you use any good IDE that speaks [[Maven]] (hint try [[NetBeans]] 7.3). Your development comfort even increases. For example you'll be able to debug your [[Java]] code. | + | Play with them, modify them. Of course, if you use any good IDE that speaks [[Maven]] (hint try [[NetBeans]] version 7.3 or higher). Your development comfort even increases. For example you'll be able to debug your [[Java]] code. |
+ | |||
+ | You can also execute the project in a browser, see [[Bck2BrwsrViaCLI]]. | ||
+ | |||
+ | == Contribute == | ||
+ | |||
+ | The [[Knockout4Java]] is now a [[NetBeans]] project (see [[Html4Java|its wiki]]) and the main development repository is hosted at https://github.com/jtulach/html-java-api/ The project is dual licensed under [[CDDL]] and [[GPLwithClassPathException]] (the same license as rest of [[NetBeans]] code), so it should be friendly enough to be used in your own applications. | ||
+ | |||
+ | Your contributions are more than welcomed. Let's make this project a base for modern user interface based on [[HTML]] for next version of [[NetBeans]] and other platforms that can render [[HTML]]! | ||
{{#ev:bliptv|6588275}} | {{#ev:bliptv|6588275}} | ||
Line 34: | Line 42: | ||
<comments/> | <comments/> | ||
+ | |||
+ | [[Category:Video]] [[Category:Bck2Brwsr]] |
Current revision
Knockout4Java is one of the subprojects of Apache NetBeans. It builds on Knockout.js, which is a powerful and attractive JavaScript library. It is lightweight and does its job (e.g. binding between a model and an HTML page) so well, that I decided to use it in my Bck2Brwsr and FXBrwsr projects and bind it together with JSON4Brwsr APIs.
Knockout for Java
Are you coming from a Java camp, yet interested in rendering via HTML? Well, then you can either use DukeScriptInNetBeans or stay on command and be just three steps (in case you have Maven and JDK7 installed) away from reaching a nirvana. Just type:
$ mvn archetype:generate \ -DarchetypeGroupId=com.dukescript.archetype \ -DarchetypeArtifactId=knockout4j-archetype \ -DarchetypeVersion=0.16
Answer few questions (for example choose myfirstbrwsrpage as artifactId) and then you can:
$ cd myfirstbrwsrpage $ mvn package $ mvn -f client process-classes exec:exec
In a few seconds (or minutes if Maven decides to download the whole Internet of dependencies) you should see a sample Hello World application. It is basically composed from one Java and one HTML file:
$ ls client/src/main/java/**/DataModel.java $ ls client/src/main/webapp/pages/index.html
Play with them, modify them. Of course, if you use any good IDE that speaks Maven (hint try NetBeans version 7.3 or higher). Your development comfort even increases. For example you'll be able to debug your Java code.
You can also execute the project in a browser, see Bck2BrwsrViaCLI.
Contribute
The Knockout4Java is now a NetBeans project (see its wiki) and the main development repository is hosted at https://github.com/jtulach/html-java-api/ The project is dual licensed under CDDL and GPLwithClassPathException (the same license as rest of NetBeans code), so it should be friendly enough to be used in your own applications.
Your contributions are more than welcomed. Let's make this project a base for modern user interface based on HTML for next version of NetBeans and other platforms that can render HTML!
Let me know what features you miss and what other you'd like to see in the FXBrwsr project.
<comments/>