Česky   |  Deutsch   |  English   |  Español   |  Français   |  Indonesia   |  日本語   |  한글   |  Polski   |  Português (BR)   |  Türkçe   |  中文   |  正體中文   |  Your Language  
PlanetNetbeans
Planet NetBeans is an aggregation of NetBeans related musings from all over the Blogosphere.
Feeds
[RSS 1.0 Feed] [RSS 2.0 Feed]
[FOAF Subscriptions] [OPML Subscriptions]
Do you blog about NetBeans ? Add your blog to PlanetNetBeans.
Feed Subscriptions
NetBeans Zone - The social network for developers (feed)
APIDesign - Blogs (feed)
ludo's blog (feed)
pandaconstantin's blog (feed)
hansmuller's blog (feed)
pkeegan's blog (feed)
richunger's blog (feed)
tball's blog (feed)
timboudreau's blog (feed)
David R. Heffelfinger (feed)
Carsten Zerbst's Weblog (feed)
Winston Prakash's Weblog (feed)
Need to find a title (feed)
Roger Searjeant's blog (feed)
Optonline Webmail (feed)
Michael's blog » NetBeans (feed)
DukeScript (feed)
ProNetBeans (feed)
Tim Boudreau (feed)
Paulo Canedo » NetBeans English (feed)
Bistro! 2.0 (feed)
Anchialas' Java Blog (feed)
markiewb's blog (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary (feed)
Java, business and... NetBeans ! [[ Jonathan Lermitage ]] - NetBeans IDE (feed)
Neil's Dev Stuff (feed)
Category: NetBeans | Software and Science (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
Inspiration and Expression » Netbeans (feed)
John O'Conner » NetBeans (feed)
Koberoi Oracle (feed)
Adam Bien (feed)
Ignacio Sánchez Ginés » NetBeans (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
NetBeans Ruminations » NetBeans (feed)
Tiplite » netbeans (feed)
Arun Gupta, Miles to go ... (feed)
Geertjan's Blog (feed)
.JARa's Bilingual Weblog (feed)
JavaFX Composer (feed)
The Java Jungle (feed)
Jesse Glick (feed)
Martin Grebac (feed)
The NetBeans Community Podcast (feed)
NetBeans Profiler (feed)
NetBeans for PHP (feed)
NetBeans Web Client (feed)
Rechtacek's (feed)
Virtual Steve (feed)
My First Blog - Satyajit Tripathi (feed)
The Aquarium (feed)
Tinuola Awopetu (feed)
Insert Witty Irony Here (feed)
Gualtiero Testa » Netbeans (feed)
James Selvakumar's Blog » netbeans (feed)
nB gUru » NetBeans (feed)
Newsintegrator Blog » netbeans (feed)
Praxis LIVE » NetBeans (feed)
TechAshram » NetBeans (feed)
There's no place like 127.0.0.1 » Netbeans (feed)
mkleint (feed)
NetBeans Community Docs Blog (feed)
The Netbeans Experience (feed)
NbPython/ jpydbg / pymvs (feed)
Shanbag's Blog (ರಜತ ಲೋಕ) (feed)
Wade Chandler's Programming Blog (feed)
Devlin's Lab (feed)
Bernhard's Weblog (feed)
Big Al's Blog (feed)
Code Snakes (feed)
In perfect (spherical) shape (feed)
Van Couvering Is Not a Verb (feed)
Diego Torres Milano's blog (feed)
Vroom Framework (feed)
Messages from mrhaki (feed)
Jeff's Blog (feed)
Oliver Wahlen's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
Netbeans IDE Blog by Tushar Joshi, Nagpur (feed)
Devel Blog (feed)
diamond-powder (feed)
Manikantan's Netbeans (feed)
Antonio's blog (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
May 25, 2015 02:05 PM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
NetBeans Zone - The social network for developers - May 25, 2015 08:14 AM
Ivar Grimstad: My Five Favorite NetBeans IDE Features!

Continuing a series of articles focusing on NetBeans users and their five favorite NetBeans IDE features, here's the next part, by Ivar Grimstad. -- NetBeans team. Preview Text:  With NetBeans, you get a complete tool suite for enterprise development. No need to download anything extra unless you absolutely want to. The Maven integration is...

Adam Bien - May 25, 2015 07:19 AM
"Playing With Nashorns" Session from itKonekt Conference

"Playing With The Nashorns" conference session from the itKonekt conference at May 23rd, 2015:

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 24, 2015 04:37 AM
News from the Modular JavaFX Application Framework

The last time I reported on the status of the mFX project was in July last year.

The biggest problem at that time was that the mouse didn't work on the menus. I ran the project again today and I guess my JDK is different (newer) than what I was using at that time because now that problem is fixed, without any changes in my code, i.e., something has been enhanced on the JavaFX level.

Click to enlarge the image below to see a JavaFX application on top of mFX:

The remaining problem is that the window system is still in Swing. If the tabs could somehow be rewritten to JavaFX (and I have tried several things without success) then the entire application would be stylable via CSS.

Aside from that, it's looking pretty good. Above, you see a CSS-styled label that updates itself, via NetBeans Lookup, based on whatever the user has chosen in the selector window in the top right. There's an editor module, a viewer module, and a domain module, in other words, mFX truly enables you to do modular JavaFX development, using all the techniques provided out of the box by the NetBeans Platform, i.e., modularity, loose coupling, and pluggability.

Adam Bien - May 22, 2015 02:17 PM
MVC, Models and Java EE 8

The Model-View-Controller (MVC 1.0) Specification (JSR-371) enables unmanaged POJOs to be used as models:

You will find an executable example at: https://github.com/AdamBien/javaee8-mvc-sample.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 22, 2015 07:00 AM
javafx.scene.media.MediaPlayer in the NetBeans Platform

Let's integrate javafx.scene.media.MediaPlayer in a NetBeans Platform application so that you can, for example, have an interesting TopComponent like the below.

Steps:

  1. Copy this class into a NetBeans module.

  2. In your TopComponent, which here is named 'NBMediaPlayerTopComponent':
    public NBMediaPlayerTopComponent() {
    
        initComponents();
    
        setName(Bundle.CTL_NBMediaPlayerTopComponent());
        setToolTipText(Bundle.HINT_NBMediaPlayerTopComponent());
    
        setLayout(new BorderLayout());
        JPanel playerpanel = new JPanel();
        final JFXPanel jFXPanel = new JFXPanel();
        playerpanel.add(jFXPanel);
        add(playerpanel, BorderLayout.CENTER);
    
        Platform.setImplicitExit(false);
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                initFxLater(jFXPanel);
            }
        });
    
    }
    
    private static void initFxLater(JFXPanel panel) {
        MediaPlayer mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
        mediaPlayer.setAutoPlay(true);
        mediaPlayer.setVolume(20.0);
        panel.setScene(new Scene(new MediaControl(mediaPlayer)));
    }
    

References:

http://docs.oracle.com/javafx/2/swing/MediaControl.java.htm

http://stackoverflow.com/questions/22364461/swing-and-javafx

http://stackoverflow.com/questions/15479821/javafx-mediaplayer-volume-trouble-why-the-volume-of-mediaplayer-do-not-chang

https://platform.netbeans.org/tutorials/nbm-javafx.html

Geertjan's Blog - May 21, 2015 06:43 PM
Open LaTeX Studio

Open LaTeX Studio is a lightweight LaTeX editor, with LaTeX code syntax highlight, code completion and live preview of the document in edition. It allows generating PDF files from the editor and provides Dropbox support, by allowing to connect the application with the Dropbox account, saving and uploading files to the remote directories and providing version control of the remote files. The application is delivered for the Windows and Linux platforms.

The project is Open source and is developed as a part of the master's thesis of Sebastian Brudziński.

It is built using the NetBeans Platfrorm 8. The code repository is located at:

https://github.com/sebbrudzinski/Open-LaTeX-Studio

and the application website is:

http://sebbrudzinski.github.io/Open-LaTeX-Studio/


DukeScript - May 21, 2015 09:53 AM
New Version of Controlsjs DukeScript Plugin

Position has released a version 2.0 of their NetBeans Plugin for controlsjs.

Controls.js is a technology for building modern web and mobile applications. Controls.js is fully integrated with DukeScript. DukeScript applications are plain Java applications that internally use HTML5 technologies and JavaScript for UI rendering. That is where Controls.js can help. Just write an application in Java, design the application user interface in Controls.js Form Editor and run your application on iOS, Android or in a standard web browser. The main features of this plugin are to provide new project wizard and integration of Controls.js Form Editor.

While DukeScript wants you to get rid of JavaScript this goes even further. It wants you to get rid of HTML and CSS as well. It’s really nice to create your DukeScript applications simply via Drag & Drop.

Download and install the Plugin either from the Plugin Portal or install it from inside the IDE. Go to Tools->Plugins, and make sure that in “settings” tab the “Certified Plugins” are activated. Then switch to “Available Plugins”, click “Check for Newest” and install “Controls.js Support for Java”.

For more info check here.

Geertjan's Blog - May 20, 2015 12:42 PM
NetBeans Day Twente

Today NetBeans Day was held in Twente, which is an area in the east of the Netherlands, with a high population of grass and farm animals. The turnout was great, exactly as expected, though the narrow focus on MooTools, while relevant for the audience, limited active participation to cows only:

The photo above was taken during the workshop "JavaScript Developers Are Basically Sheep", which had as a subtitle "Weakly Typed Languages Are For The Birds".

Did you miss NetBeans Day Twente? Not to worry, there's NetBeans Day UK coming up end of this month and NetBeans Day Brazil end of the next!

Adam Bien - May 20, 2015 07:26 AM
beans.xml and JAXRSConfiguration: javaee7-essentials-archetype v1.3 released

The version 1.3 javaee7-essentials-archetype comes with two features:

  1. beans.xml for Java EE 7 and bean-discovery-mode="all" is created
  2. JAXRSConfiguration class mapped to the "resources" path enables JAX-RS

Create a project directly from the IDE (in NetBeans: New Project -> Maven -> Project From Archetype. Choose com.airhacks as groupId in the search box).

Or use the CLI:


mvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype

If you like to stay lean without beans.xml and JAXRSConfiguration, choose the version v1.2.

The archetype's source is available at: https://github.com/AdamBien/javaee7-essentials-archetype. The project can be also directly cloned from: https://github.com/AdamBien/javaee-essentials-pom

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - May 19, 2015 03:17 PM
NetBeans in the Classroom: Using the NetBeans Rest Service Wizard

Ken Fogel is the Program Coordinator and Chairperson of the Computer Science Technology program at Dawson College in Montreal, Canada. He is also a Program Consultant to and part-time instructor in the Computer Institute of Concordia University's School of Extended Learning. Preview Text:  Ken Fogel, the Program Coordinator and Chairperson of the...

NetBeans Zone - The social network for developers - May 19, 2015 11:09 AM
Handy Tools for HTML5 Client Development

I had a chance to work a bit more with NetBeans and HTML5 client development this week and some of the features that really came in handy were: Preview Text:  I had a chance to work a bit more with NetBeans and HTML5 client development this week and some of the features that really came in handy are described here! Legacy ...

Adam Bien - May 19, 2015 06:20 AM
Auto-Creating JMS Destinations With JMS 2.0 and Java EE 7

Java EE 7 and JMS 2.0 introduced the @JMSDestinationDefinitions annotation which allows automatic creation of JMS resources at deployment time:


import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.jms.JMSDestinationDefinition;
import javax.jms.JMSDestinationDefinitions;

@JMSDestinationDefinitions(
        value = {
            @JMSDestinationDefinition(
                    name = "java:/queue/duke-queue",
                    interfaceName = "javax.jms.Queue",
                    destinationName = "duke"
            ),
            @JMSDestinationDefinition(
                    name = "java:/topic/duke-topic",
                    interfaceName = "javax.jms.Topic",
                    destinationName = "duke-topic"
            )
        }
)
@Startup
@Singleton
public class Initializer {
     
    @Resource(lookup = "java:/queue/duke-queue")
    private Queue queue;      
    
    @Produces
    public Queue expose() {
        return this.queue;
    }
}

The conveniently created JMS destination (Queue or Topic) can be immediately exposed to dependency injection with the CDI @Produces annotation.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 19, 2015 06:02 AM
Knockout Simplicity for Bootstrap.css (Part 2)

Continuing the theme from the previous blog entry, here's the current state of my 'menubar' component, i.e., this is all I need to put into an HTML file...

...to get this:

The above is a Bootstrap.css menubar, created from the Knockout component shown above.

The HTML below is the template that styles the menubar, notice that there's JavaScript logic, thanks to Knockout, within the template:

Finally, here's the business logic that connects the template to the component, which receives its parameters from the component:


DukeScript - May 17, 2015 04:53 PM
Here it is, the inevitable Twitter Demo!

OK, drum roll, raise the curtain, clear the stage, here it is, the inevitable return of the Twitter demo. This time in DukeScript.

It’s OK to roll your eyes, but let’s face it, no technology is complete without a Twitter client written in it. Twitter client is the new “Hello World”! And rightfully so. A Twitter client demonstrates a lot of essential techniques, for example how to authorize an application and how to consume web services.

Our Twitter Client will use Application level authorization.

DukeScript, JSON and the REST

Consuming REST Web Services and parsing JSON results in DukeScript is simple. That’s good, because the Twitter API produces JSON. We just need to create a ViewModel class that has all the properties of the Message we’re interested in. You can have a look at this blog entry for more details.

Here’s the ViewModel of a tweet:

@Model(className = "Tweet", properties = {
        @Property(name = "from_user", type = String.class),
        @Property(name = "from_user_id", type = int.class),
        @Property(name = "profile_image_url", type = String.class),
        @Property(name = "text", type = String.class),
        @Property(name = "created_at", type = String.class),})
    static final class Twt {
        //...
    }

We can now send a Query to the API, let DukeScript parse the tweets, organize them in a ViewModel with some additional functionality, like adding or deleting Twitter Users we’re interested in, and so on. I don’t want to show that code here. You can look it up on Github, where the project is hosted.

In this blog post we’ll have a look at something much more interesting. We’ll have a look at how to extend Dukescript’s functionality. Because we need to work around a limitation in the current version of DukeScript.

DukeScript SPIs, registering your own Transfer

The API for consuming REST messages works fine if we can encode everything in the URL. But sometimes we need to set Request Headers. The Twitter API for example requires us to set a Bearer token in an Authorization Header. That’s currently not supported in DukeScript. So we need to change the default behaviour.

Fortunately DukeScript was created with extensibility in mind. So we can create our own implementations for the DukeScript SPIs. For changing the way data is sent, we need to register our own Transfer.

We need to set some additional Headers, the rest of the functionality is fine, so let’s simply copy the default implementation classes (Transfer, LoadJSON, LoadWS) and make some small changes to the loadJSON method in class LoadJSON:

@JavaScriptBody(args = {"url", "done", "method", "data"}, javacall = true, body
            = "console.log(url);"
            + "var request = new XMLHttpRequest();\n"
            + "if (!method) method = 'GET';\n"
            + "var res = url.split('|');\n"
            + "url = res[0];"
            + "console.log(url);"
            + "request.open(method, url, true);\n"
            + "request.setRequestHeader('Content-Type', 'application/json; charset=utf-8');\n"
            + "if (res.length > 1){\n"
            + "  for (i = 1; i < res.length; i++) { \n"
            + "    var head = res[i].split(':');\n"
            + "    if (head.length == 2){\n"
            + "           console.log(head[0]);"        
            + "           console.log(head[1]);"        
            + "       request.setRequestHeader(head[0], head[1]);\n"
            + "    }\n"
            + "  }\n"
            + "}\n"
            + "request.onreadystatechange = function() {\n"
            + "  if (request.readyState !== 4) return;\n"
            + "  var r = request.response || request.responseText;\n"
            + "  try {\n"
            + "    var str = r;\n"
            + "    if (request.status !== 0)\n"
            + "      if (request.status < 100 || request.status >= 400) throw request.status + ': ' + request.statusText;"
            + "    try { r = eval('(' + r + ')'); } catch (ignore) { }"
            + "    @com.dukescript.twitterdemo.transfer.AuthorizedTransfer::notifySuccess(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)(done, str, r);\n"
            + "  } catch (error) {;\n"
            + "    @com.dukescript.twitterdemo.transfer.AuthorizedTransfer::notifyError(Ljava/lang/Object;Ljava/lang/Object;)(done, error);\n"
            + "  }\n"
            + "};\n"
            + "request.onerror = function (e) {\n"
            + "  @com.dukescript.twitterdemo.transfer.AuthorizedTransfer::notifyError(Ljava/lang/Object;Ljava/lang/Object;)(done, e.type + ' status ' + request.status);\n"
            + "}\n"
            + "if (data) request.send(data);"
            + "else request.send();"
    )
    static void loadJSON(
            String url, JSONCall done, String method, String data
    ) {
    }

Now we’re able to pass RequestHeaders through the URL. loadJSON will parse them and add them to the request. The next thing we need to do is register this behaviour to replace the default implementation. For this we create ‘RegisterTransfer’, a class responsible for, well, registering, the Transfer (I renamed my Transfer to ‘AuthorizedTransfer’):

@ServiceProvider(service = Contexts.Provider.class)
public class RegisterTransfer  implements Contexts.Provider {

    @Override
    public void fillContext(Contexts.Builder context, Class<?> requestor) {
        context.register(Transfer.class, new AuthorizedTransfer(), 10);
    }
}

The class itself is annotated as a ServiceProvider. As a result during compilation a file will be created in the META-INF/services directory that registers it declaratively. When the application is running all registered Context.Providers will be instantiated. DukeScript will call their service method fillContext. This is how our AuthorizedTransfer will get added to the system as an implementation of the Transfer SPI. The Integer number is the Rank of our Service. Smaller is better here, so our Service will be used instead of the default Implementation, which has a rank of 100.

One additional little step is required for this to work. We need to modify the pom.xml to include the META-INF/services in the jar.

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.dukescript.twitter.js;META-INF.services</Export-Package>
                        <Bundle-SymbolicName>com.dukescript.twitter.js</Bundle-SymbolicName>
                    </instructions>
                </configuration>                
            </plugin>

Now our implementation is registered and we can use it:

@OnPropertyChange({"activeTweeters", "activeTweetersCount"})
    static void refreshTweets(TwitterModel model) {
        if (model.getActiveTweeters().isEmpty()) return;
        StringBuilder sb = new StringBuilder();
        sb.append("q=");
        String sep = "";
        for (String p : model.getActiveTweeters()) {
            sb.append(sep);
            sb.append(p);
            sep = "%20OR%20";
        }
        sb.append("|Authorization: Bearer ");
        sb.append(BEARER_TOKEN);
        
        model.setLoading(true);
        model.queryTweets("https://api.twitter.com/1.1/search", sb.toString());
    }

The rest of the application is plain DukeScript. So check it out on github. In order to run the demo, you will need to get a bearer token from Twitter. That means you need to register an app here and then get the Consumer Key (API Key) and Consumer Secret (API Secret). You’ll find those values in your app registration in section Keys and Access Tokens.

With these values you can request a Bearer Token. I’ve just uploaded a utility class to the github project that you can use like this:

String bearerToken = BearerTokenUtil.getBearerToken(  CONSUMER_KEY, CONSUMER_SECRET);

You have to create the bearer token only once. It will usually only change at your own request.

APIDesign - Blogs - May 17, 2015 10:26 AM
API Design as a Service

Domain Expert is a person who has knowledge of a particular system. With such knowledge it may seem easy to design APIs for the domain. However without understanding the API Paradoxes the quality of such API may not be high. It is likely going to cover the domain field, but the API usability or readiness for evolution will very likely suffer (unless such Domain Expert reads TheAPIBook first).

However can it work backwards? E.g. can one be just an API expert and then design good enough API without appropriate domain knowledge?

I am now participating in an experiment that will check that. OracleLabs guys asked me to help them design Truffle interoperability APIs. I do understand bit about Truffle, but certainly I am not a Domain Expert, yet I am supposed to design something as complicated as API to allow mixing of languages: imagine part of program written in Ruby, part in JavaScript, part in Java with objects floating between these languages without any borders!

This is a new situation for me: In case of NetBeans or in case of HTML/Java APIs, I was also the architect of the system. I knew it by heart. Now I barely understand how Truffle works and what makes it the fastest execution system for dynamic languages. My biggest fear is that I will design something that will be inherently slow.

On the other hand, I am not yet damaged with the expert knowledge. I can still see the system with new comer eyes - just like you, users of Truffle will. As such I can perform a usability study on me, at least initially.

If I can design easy to use APIs for Truffle, then I can create a perfect API facade around everything! Soon we'll have a chance to see whether one can be good API designer without being real Domain Expert. Soon we'll find out if API Design can be offered as a service!

--JaroslavTulach 10:26, 17 May 2015 (UTC)

Adam Bien - May 17, 2015 08:00 AM
Playing With Model View Controller MVC (JSR-371) from Java EE 8

Playing with JSR-371 MVC (Reference Implementation) ozark scheduled to ship with Java EE 8.

See also executable example: https://github.com/AdamBien/javaee8-mvc-sample

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 17, 2015 07:27 AM
Knockout Simplicity for Bootstrap.css (Part 1)

Imagine you need to create a menubar for your website:

If you had a choice, which of the two below would you choose as the way to express your menubar?

In both cases, you start by declaring Bootstrap.css:

<link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>

However, which of the two would you prefer to use, after you have added the stylesheet reference above?

Option 1:

Option 2:


Of course, it's up to you and I won't judge you either way. However, to me, option 2 is much simpler and more expressive. Plus, I can use it in any website where I need a menubar, i.e., it's a simple lightweight generic tag in my HTML ready to be used anytime I need a menubar. It also means I don't need to type all that error-prone HTML code and it is also a lot more readable, as well. It looks a bit like JSON, while option 1 is very heavily loaded with angle brackets and other superfluous noise.

Option 2 is a Knockout component.

It is created like this, in my 'appViewModel.js' file:

ko.components.register("menubar", {require: 'components/menubar/menuBar'});

The above points to a JavaScript file named 'menuBar.js', which has this content:

define([], function () {
    function MenuBarModel(params) {
        self.menus = [];
        for (var key in params) {
            if (key.substring(0, 3)==('tab')) {
                self.menus.push(params[key]);
            }
        }
    }
    return {
        viewModel: MenuBarModel,
        template: {
            require: 'text!components/menubar/menuBar-template.html'
        }
    };
});

Above you see the 'template' binding points to an HTML file, which has this content:

<div class="navbar">
    <div class="navbar-inner">
        <ul class="nav" data-bind="foreach: menus">
            <li data-bind="css:  { active: $data.substring(0,1) == '*' }">
                <a data-bind="attr: { href: $data.substring($data.indexOf('/')+1) }">
                    <span data-bind="text: $data.substring(1,$data.indexOf('/'))"/>
                </a>
            </li>
        </ul>
    </div>
</div>

And now you can make the menubar a lot fancier: http://www.w3schools.com/bootstrap/bootstrap_case_navigation.asp

By means of the above, we have a simple syntax to define (1) the active menu, (2) the name of the menu, and (3) the URL that is returned when the menu is clicked. The Knockout 'menubar' component figures all these things out under the hood so that the user of the menubar doesn't have to think about it themselves. They simply specify the values that should be passed into the component and the component parses the value and figures out what to do with it.

The above provides a simple and comprehensive architecture for component-based development with JavaScript.

Geertjan's Blog - May 16, 2015 07:01 AM
Porting Knockout Components to DukeScript

With Knockout, you can extend the DOM by means of widgets, also known as 'components', such as the "user" component that you see below, which has the parameters "firstName" and "lastName":

As discussed yesterday and the day before in this blog, a component is created in JavaScript, like this:

ko.components.register('user', {
    viewModel: function (params) {
        this.firstName = ko.observable(params.firstName);
        this.lastName = ko.observable(params.lastName);
        this.fullName = ko.pureComputed(function () {
            return this.firstName() + " " + this.lastName();
        }, this);
    },
    template:
        'First Name: <input data-bind="textInput: firstName"/>\
        <br/>\
        Last Name: <input data-bind="textInput: lastName"/>\
        <h2 data-bind="text: fullName"></h2>'
});

As you can see here, by means of 'ko.components.register', you're able to register a new component, which is named 'user' here, consisting of a viewmodel and a template.

Now let's imagine we're using DukeScript, i.e., the WORA framework for Java programmers. Imagine you have several Knockout components like the above, how would you integrate them into your DukeScript application?

One of the Maven projects provided by the DukeScript Maven archetype has "JavaScript Libraries" in its name:

Notice that in the above there's a JavaScript file named 'userEntryComponent.js'. The content of that file is the 'user' component described in code at the start of this blog entry. Also notice that there is a Java source file in the above screenshot, named 'UserEntryWidget.java', which has this content:

package org.demo.ko4j.DemoKO4J.js;

import net.java.html.js.JavaScriptBody;
import net.java.html.js.JavaScriptResource;

@JavaScriptResource(value = "userEntryComponent.js")
public final class UserEntryWidget {

    private UserEntryWidget() {
    }

    @JavaScriptBody(args = {}, body = "")
    public static native void registerComponent();

}

Notice that there is a reference to the JavaScript file, as well as a static method named 'registerComponent'.

OK, congratulations, you have ported your Knockout component to DukeScript, which consists of (1) copying the JavaScript file into the correct place in the DukeScript application structure and (2) registering it via the @JavaScriptResource annotation shown above.

The final step is to use the component. In the 'Main.java' class, i.e., in the Maven project where the client code is defined, you need the following:

public static void onPageLoad() throws Exception {
    Data d = new Data();
    Models.toRaw(d); // this line is required to initialize knockout
    UserEntryWidget.registerComponent();
    d.applyBindings();
}

Notice the two lines in bold above. Notice that we're calling the static method in the UserEntryWidget class above. Also notice that we do not initialize the Data class above, i.e., we do not need to use 'setFirstName' and 'setLastName' on the Data class, because the initialization is done when you make use of the 'user' component, as you can see in the first screenshot above.

That's all you need to do to include a Knockout component in a DukeScript application.

DukeScript - May 15, 2015 11:53 AM
On device debugging for iOS!

We’re proud to announce the latest version of the DukeScript archetypes has been released to Maven Central. The greatest new feature is support for on-device debugging on iOS. If you have installed the NetBeans Plugin, the new archetypes will be used automatically. So you don’t need to install or update anything. Just create a new project.

In order to get debugging to work, you will need a license from RoboVM (There’s a 14 day trial available). After installing your license, simply start your app using the “debug” action in the projects context menu. This will launch your app in the iPad Simulator. To debug on an iOS device connected to your Mac, switch to the “Files” tab and add this to your nbactions.xml:

<action>
        <actionName>CUSTOM-debug-on-device</actionName>
        <displayName>Debug on iOS Device</displayName>

        <goals>
            <goal>package</goal>
            <goal>robovm:ios-device</goal>
        </goals>
        <properties>
            <skipTests>true</skipTests>
            <robovm.debug>clientmode</robovm.debug>
            <robovm.debugPort>${jpda.address}</robovm.debugPort>
            <jpda.listen>true</jpda.listen>
        </properties>
    </action>

This will add a new entry “Debug on iOS Device” to the “Custom”-submenu. The new task will automatically be available in the upcoming release of the DukeScript NetBeans Plugin.

If you prefer creating your projects from the command-line, the version number is 0.9.

Use this Archetype to create a basic application:

mvn archetype:generate 
	-DarchetypeGroupId=com.dukescript.archetype
	-DarchetypeArtifactId=knockout4j-archetype 
	-DarchetypeVersion=0.9

The second archetype creates a CRUD application that shows how you can do client-server communication and reuse Model code on both ends:

mvn archetype:generate 
	-DarchetypeGroupId=com.dukescript.archetype
	-DarchetypeArtifactId=crud4j-archetype 
	-DarchetypeVersion=0.9

For on device debugging with Android, you’ll have to wait for NetBeans 8.1. The archetypes support it already. If you can’t wait, use a development build of NetBeans.

The Source Code of the new version of the presenters is available on Github:

https://github.com/dukescript/dukescript-presenters

We have also published the sources for the Maven Archetypes:

https://github.com/dukescript/maven-archetypes

Geertjan's Blog - May 15, 2015 08:45 AM
require.config with Knockout in NetBeans

The application structure discussed yesterday is as follows:


Thanks to require.config, here's a significantly cleaned up version of the code discussed yesterday in 'init.js':

require.config({
    baseUrl: './',
    paths: {
        knockout: './bower_components/knockout/dist/knockout',
        text: './bower_components/requirejs-text/text',
        appViewModel : './scripts/appViewModel'
    },
    waitSeconds: 2
});
require(['knockout', 'appViewModel', 'text'], 
   function (ko, appViewModel) {
     ko.applyBindings(new appViewModel());
   }
);

Putting the above together was simplified via the code completion and documentation in NetBeans:

What's also pretty handy is that you can see all the available configurations when you call up code completion before the start of a word within a 'require.config' block:


And here's the 'appViewModel', also significantly cleaned up, thanks to the 'require.config' in the 'init.js' above:

define([
    'knockout',
    'text'
],
function (ko) {
    return function appViewModel() {
        ko.components.register("user", {
            viewModel: function (params) {
                this.firstName = ko.observable(params.firstName);
                this.lastName = ko.observable(params.lastName);
                this.fullName = ko.pureComputed(function () {
                    return this.firstName() + " " + this.lastName();
                }, this);
            },
            template: {require: 
                'text!files/user-template.html'}
        });
    };
});

Again, notice the editor support below, not only syntax coloring, but when you hold down the Ctrl key and move your mouse over the file reference in the 'text' binding, in line 16 below, the reference becomes a hyperlink, which can be clicked to open the related file.


As shown yesterday, the final step of this scenario is to actually make use of the 'user' component in the view, where again NetBeans has helpful code completion to support you:

The application is modulerized and wired together via RequireJS, with its 'data-main' attribute, e.g., in the 'index.html', where the above is found, there is also the below, providing the entry point into the application, which is the 'init.js' file with which this blog entry started:


More on RequireJS (sorry for the poor audio): https://www.youtube.com/watch?v=v4jnTWFihMU

Adam Bien - May 14, 2015 09:39 PM
An Interview With the Killerfish--Payara

Q: C2B2 already provided commercial support for GlassFish, what is the idea behind www.payara.co?

Payara is a new initiative for C2B2. Previously we provided operational support and consultancy for customers using GlassFish in production. With Payara we are going a completely different direction. We are using the upstream open source GlassFish code base as our core to build a new application server, Payara.

We are looking to build new capabilities into Payara Server and recently we’ve added in JSR107 and data grid capabilities by incorporating Hazelcast. I did a webinar on this with Hazelcast last month: http://www.payara.co/javaee_applications_supercharged_ldquo_using_jc. We are also investigating new deployment scenarios for cloud and micro services environments through Payara Micro; and we aim to connect with the wider DevOps ecosystem through integrations with tools like Chef, Puppet, Ansible, Docker and Kubernetes.

Q: Have you got any feedback from Oracle about your Payara activities?

We have had no official feedback from Oracle. A number of our employees have signed the Contributor Licensing Agreement with Oracle and so can now submit fixes back to the upstream GlassFish team.  A number of these have been incorporated into the current GlassFish nightly builds. Informally, we’ve had support and encouragement from some of the engineers of the upstream GlassFish projects and in the spirit of open source they are keen for us to contribute.

Q: I've been watching Payara since JavaOne 2014 and the github account is very active. What triggers the activity?

People are using Payara and GlassFish and see that we are active, so they are reporting bugs and suggest lots of new ideas for new things they would like to see. This drives the list of things we want to add into each release. Payara is released quarterly and all development is carried out in the open on GitHub, which generates all the activity. We also see people raising questions, suggestions and issues on Twitter, StackOverflow, Facebook etc. The community has been really active and the interest is definitely growing – we’re really happy about it and we encourage all Payara and GlassFish users to get involved in the discussion!

Q: Does the community participate in Payara Development?

Absolutely! A number of people have signed the CLA and submitted pull requests for bug fixes and changes, which have been incorporated in the latest Payara release. New ideas from the community are also forming the basis of the enhancements and Payara Micro is a direct result of ideas from the community of how they would like to run their Java EE applications. We are completely open to community contributions and ideas. To be honest, we can’t think of everything ourselves, so we are very keen to get other people’s cool ideas to implement. GitHub is the central place to participate but people can ask questions on Twitter and other social media platforms, or even come along to one of the Java EE & GlassFishUser Group sessions in London (more info http://www.meetup.com/GlassFish-User-Group/).

Q:How many GlassFish users are switching to Payara? Can you give us any rough ideas?

There are a number of people we are aware of who are planning to or have already switched to Payara, including some very well know companies. We have been pleasantly surprised at how quickly the level of interest has grown and the speed at which some organisations are planning to switch. The level of interest and demand is growing and this spurs us on to make Payara better and better.

Q:How hard was the implementation of Payara Micro Edition?

To be honest, it was pretty easy to get the initial release of Payara Micro out. Not a lot of people know, but GlassFish has had an embedded edition for a long time. We’ve built on GlassFish embedded and our new Hazelcast integration to produce our first version of Payara Micro. A lot of the work we did was packaging GlassFish embedded in such a way that we could get more JavaEE capabilities and to get full web session clustering. The new Hazelcast integration gave us Dynamic Clustering which is fundamental to Payara Micro.

For us, Payara Micro marks the beginning of development in new ways of deploying JavaEE applications in radically new topologies. I’ve recently written an overview of Payara Micro which can be found on our blog: http://www.payara.co/introducing_payara_micro. We have a lot of cool ideas for taking Payara Micro in an exciting direction so stay tuned.

Q:Do you know any cool projects using Payara?

We are aware of projects using or planning to use Payara in many different cool ways e.g. for SAAS, Point of Sale, Intranet and Microservices. You should hear more about this in the near future as we are already gathering some success stories to publish on our website soon. Also, if you continue to blog about cool projects like the recent dreamIT one, I’m sure we’ll hear more on your blog ;-)

Q:What is your opinion about Java EE? Is it productive? How many of your customers are using it?

Is JavaEE productive? Absolutely! You can create applications in very few lines of code using a standard IDE like NetBeans with zero IDE setup. Producing a standard war file which can then be run on the command line with java –jar payara-micro.jar –deploy your.war. What could be more productive? You don’t need complex dependency management, complex installations or weird XML configuration files any more. I’ve got a talk at NetBeans Day in London on the 29th of May which will build and run a simple JavaEE application in 45 minutes: https://blog.idrsolutions.com/2015/03/netbeans-day-uk-friday-29th-may-2015/

Q:What are the features of the current release?

The latest release added Payara Micro; a small footprint version of Payara that requires no pre-installation and can run war files from the command line. Saying that, Payara Micro supports applications that use Java EE web profile apis along with JBatch, Concurrency and JCache. It also auto-clusters to give full web session replication across multiple Payara Micro instances.

From core GlassFish we’ve replaced the Shoal based clustering with Hazelcast as an embedded Data Grid which gives us JCache support and dynamic clustering capabilities. We’ve extended the range of JBatch persistence providers by adding support for MySQL, Oracle and DB2. Along with numerous critical bug fixes and upgrades to a lot of the underlying components like Jersey, Tyrus and Grizzly etc.

Q:What are the next cool features we can expect on Payara?

We are focusing on a number of areas.

Payara Micro is going to morph and grow into a fundamentally different way of installing and managing Java EE applications. Targeted at dynamic cloud environments and large scale installations. Our long-term goal is to make 1000 Payara Micro instances manageable from a single console on the cloud. We are looking at how RTS games present a lot of information to a user on the status of their units as a model for building a new management console for the cloud.

We have a focus on manageability and are starting to build in transaction tracing and fault finding capabilities to identify problems and make the operator aware of them as they happen so you don’t have to dig around to work out what went wrong.

Finally we are also focusing on integrating with the rest of the DevOps ecosystem with tooling around Payara for Chef, Docker, Maven etc.

Q: How expensive is the commercial support? Where is the pricelist?

Our commercial support is simply based on the number of Payara servers you are running rather than cpus, cores or power factors. We have priced commercial support in 3 tiers starting from $1,500 per server per annum for the most basic support, which we hope is set at a level that even small shops can get support. Our Enterprise support which provides full 24/7 screen sharing assistance runs to $5,000 per server per annum. We’ve also added unlimited options for organisations looking to run Payara everywhere without having to keep track of the numbers of servers they run. Of course there is also open source support on GitHub on a best endeavours basis. However we want to encourage people to buy commercial support as all the money that people spend with us on support is being reinvested into cool new Payara features. You can get the full pricelist with a feature breakdown on http://www.payara.fish/support  

Steve, thank you for the interview!


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 14, 2015 12:45 PM
How to Separate HTML Templates in Knockout Apps

A problem with the solution discussed in the recent YouTube clip about component-based Knockout.js development is that you end up with your HTML template embedded in your JavaScript file, as shown below:

From a tooling perspective, the above is suboptimal because you're not able to benefit from code completion and syntax coloring that an HTML editor provides. One approach would be to create an extension to NetBeans that would somehow recognize the above construct as being HTML (i.e., if a "template" binding is encountered, treat everything that follows as HTML), which is doable and something I'll take a look into (using this as a starting point). And here's the initial result of looking into this, i.e., compare the string in the pic above to the string in the pic below; in the lower pic notice the HTML syntax coloring:


However, in a real Knockout application, you're more likely to separate out your HTML into separate files, thus making it possible to hand those HTML files over to your front-end designers, while you continue working separately on the business logic in your JavaScript files.

Starting with this useful article on the Knockout site, I restructured the application discussed in the YouTube clip so that its HTML is now separated out from the JavaScript, which has as an added benefit that all the Knockout support features available out of the box in NetBeans are available to you:

To get to the above point, I followed various articles where 'requirejs' and 'requirejs-text' are described. My application now looks like this:

And here's my 'appViewModel.js', which still has some work to be done to it (which is discussed here), i.e., I need to use 'require.config', which is the next topic I'll be looking at. However, in the meantime, here's how things are set up to get to the above point:

define([
    '../bower_components/knockout/dist/knockout',
    '../bower_components/requirejs-text/text'
],
function (ko) {
    return function appViewModel() {
        ko.components.register("user", {
            viewModel: function (params) {
                this.firstName = ko.observable(params.firstName);
                this.lastName = ko.observable(params.lastName);
                this.fullName = ko.pureComputed(function () {
                    return this.firstName() + " " + this.lastName();
                }, this);
            },
            template: {require: 
                '../../requirejs-text/text!../../../../../files/user-template.html'}
        });
    };
}); 

The rest is the same as here. Finally, as in the YouTube clip, you use the above defined 'user' component in your 'index.html' as follows, again supported by code completion and other Knockout-friendly features in NetBeans:


NetBeans for PHP - May 14, 2015 08:46 AM
Phing support added

<p> Hi all, today we will show you our support for&nbsp;PHP project build system or build tool&nbsp;which has been added in&nbsp;<strong>NetBeans 8.1</strong>. This time, we will talk about <a href="https://www.phing.info/" target="_blank" title="Phing homepage">Phing</a>.</p> <p>This support works exactly the same way as the existing support for JavaScript build tool, <b>Grunt</b> (please note that for NetBeans 8.1, we have added another popular JavaScript build tool, <b>Gulp</b>). This starts with configuration of Phing executable, of course:</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-1.png" alt="Phing executable configuration" /></p> <p>Now, we can create a new Phing build file if it does not exist in the PHP project yet:&nbsp;</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-2.png" alt="Phing build.xml template" /></p> <p>Phing build file appears among Important Files of the project:</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-3.png" alt="build.xml is Important File" /></p> <p>Phing targets can be assigned to common IDE actions in the Project Properties dialog so then, if one e.g. <i>Runs Project</i>, the relevant Phing target is automatically executed as well.</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-4.png" alt="Project Properties of Phing" /></p> <p>Any Phing target defined in project's <i>build.xml</i> can be run via project's context menu. One can even specify an <i>advanced</i> task:</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-5.png" alt="Advanced Phing target" /></p> <p>Advanced task can be configured with custom options and parameters. Moreover, more Phing targets can be run at once and every advanced task can be optionally stored in VCS so every team member can use it easily:</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-6.png" alt="Advanced Phing target configuration" /></p> <p>NetBeans remembers a few of the latest advanced tasks and allows to rerun them easily. Ordinary Phing targets can be run directly as well, of course:</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-7.png" alt="Stored advanced Phing target" /></p> <p>Output of every Phing target run can be easily found (and reviewed if needed) in the Output window:&nbsp;</p> <p><img src="https://blogs.oracle.com/netbeansphp/resource/article_images/phing-8.png" alt="Phing output" /></p> <p><span style="line-height: 18px;">That's all for today, as always, please&nbsp;</span><a title="Development version of NetBeans" target="_blank" href="http://bits.netbeans.org/download/trunk/nightly/latest/" style="line-height: 18px;">test it</a><span style="line-height: 18px;">&nbsp;and report all the issues or enhancements you find in&nbsp;</span><a href="http://netbeans.org/community/issues.html" target="_blank" title="NetBeans Bugzilla" style="line-height: 18px;">NetBeans Bugzilla</a><span style="line-height: 18px;">&nbsp;(component&nbsp;</span><em style="line-height: 18px;">php</em><span style="line-height: 18px;">, subcomponent&nbsp;</span><em style="line-height: 18px;">Phing</em><span style="line-height: 18px;">).</span><span style="line-height: 18px;">&nbsp;You can also&nbsp;</span><span style="line-height: 18px;">leave a comment here (</span><b style="line-height: 18px;">please notice that the comments are moderated so they will not appear here immediately</b><span style="line-height: 18px;">) but reporting issues is strongly preferred.</span> </p>

Geertjan's Blog - May 13, 2015 08:31 AM
YouTube: Component Based Development with Knockout.js

Knockout.js has some extremely handy facilities for doing component based development, as shown in this brand new YouTube screencast:

Adam Bien - May 13, 2015 04:19 AM
From Devoxx 2014: Pico Services with Java EE 7 on Java 8 and Docker

My presentation about (pico|micro|femto)services on Java EE from Devoxx 2014.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - May 12, 2015 09:39 PM
Eclipse Recommenders for NetBeans IDE (Part 2)

Following on from part 1 of this series, here's two interesting screenshots to look at:

Above you see Eclipse code recommenders for NetBeans APIs, which is something Andreas Sewe and Marcel Bruch, from the Eclipse code recommenders project, have been working on, together with some NetBeans guys.

Also read Marcel Bruch's tweet on this topic: https://twitter.com/MarcelBruch/status/598187743634706432

Imagine how much easier it will make learning the NetBeans APIs if the code completion box, as shown above, recommends methods to you based on the API class you're currently coding against? Really useful, indeed.

Watch this space for further development.

NetBeans Zone - The social network for developers - May 12, 2015 09:10 AM
New NetBeans Platform Trainers in US: Gail and Paul Anderson

The Anderson Software Group, led by Gail and Paul Anderson, is one of many organizations actively using NetBeans IDE, over many years. Recently they provided a great quote to the NetBeans Community site on Oracle.com, summarizing their experiences with NetBeans IDE: Preview Text:  Announcing two new certified NetBeans Platform trainers, based in...

Geertjan's Blog - May 11, 2015 07:00 AM
Selecting Content Between Braces with Ctrl-Shift-[

The question of the day comes from my colleague JB Brock who asks: "Is there some key combination (shortcut) in NetBeans that allows me to jump between an opening brace and closing brace, or even better, the ability to select everything between braces? I'm working in a JSON file and want to select a full object between { } braces.  Just looking to see if there is something that could make my life a little easier as I have 105 of these little sections that I need to strip out."

Here's how to do it. Below, notice that my cursor is on line 6, right before the opening brace, which means that its closing brace is helpfully highlighted so that you know which brace is the current opening brace's closing brace:

Now I press Ctrl-Shift-[ and this is the result:

Now you can press Ctrl-C to copy the selection to the clipboard.

In the next scenario, notice that my cursor is still in line 6, this time on the other side of the opening brace:


When I press Ctrl-Shift-[ in the above scenario, the selection covers everything excluding the opening and closing brace:

Now, again, press Ctrl-C and the content above is on the clipboard.

The above works in any other kind of file, as well, e.g., in Java, JavaScript, HTML, etc., which is precisely why it is great to have an integrated development environment—everything you know from one context has the potential to seamlessly be used in another context.

Adam Bien - May 11, 2015 03:48 AM
JAX-RS: Get swagger.json For Free!

JAX-RS analyzer maven plugin examines JAX-RS resources in your Java EE project and generates the swagger.json definition. There are no runtime dependencies, additional annotations or configuration required, you only have to include the plugin to your maven build and then mvn clean install your project:


<plugin>
	<groupId>com.sebastian-daschner</groupId>
	<artifactId>jaxrs-analyzer-maven-plugin</artifactId>
	<version>0.3</version>
	<executions>
		<execution>
			<goals>
				<goal>analyze-jaxrs</goal>
			</goals>
			<configuration>
				<!-- Available backends, defaults to plaintext -->
				<!-- <backend>plaintext</backend> -->
				<backend>swagger</backend>
			</configuration>
		</execution>
	</executions>
</plugin>


The recent release (swaggerina) of headlands ships with swagger-ui with the spec generated by the JAX-RS analyzer plugin. A drop-in WAR is also available.

Big thanks to Sebastian Daschner, an airhacks alumni, for this time-saver. I think you should star the repo: https://github.com/sdaschner/jaxrs-analyzer :-).

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - May 08, 2015 12:32 PM
Morten Bergset: My Five Favorite NetBeans IDE Features!

Continuing a series of articles focusing on NetBeans users and their five favorite NetBeans IDE features, here's the next part, by Morten Bergset in Norway. -- NetBeans team.My name is Morten Bergset, I am from Kristiansand in Norway and am a PHP developer for Profundo. Preview Text:  An IDE can give you so much more then a simple...