New HTML/Java API Version 1.2

NetBeans 8.1 will ship with a new version of the HTML/Java APIs we use in DukeScript.

This brings us a couple of new features:

HTTP request headers

The ability to set HTTP request headers when using the OnReceive annotation. The Twitter Demo has been updated to reflect these latest changes in the APIs. Authentication is getting so much simpler through this:

    @OnReceive(url = "{root}/tweets.json?{query}", headers = {
        "Authorization: Bearer {bearertoken}"
    })
    static void queryTweets(TwitterModel page, TwitterQuery q) {
         //...
    }

   // used like this:
   model.queryTweets("https://api.twitter.com/1.1/search", sb.toString(), BEARER_TOKEN);

Writable ComputedProperties

It is now possible to have writable computed properties. ComputedProperties depend on other Properties of the model. Until now they were read only. With version 1.2 we can now also write. This allows you to bind an input field to a ComputedProperty and react on changes:

From the API Doc:

 @ComputedProperty(write="setPowerValue")
 static int powerValue(int value) {
   return value * value;
 }
 static void setPowerValue(DataModel m, int value) {
   m.setValue((int)Math.sqrt(value));
 }

Firebug support

There is now an easy way to enable Firebug in the General Client for visually debugging the app. Just run with -Dfirebug.lite=true as this video demonstrates.

This way you can enable visual debugging when developing with Eclipse or IDEA. You’ll see a blog post here on how to use this in more detail soon.

In addition to that there were Bugfixes for issues 250503 and 252987.

The new version (1.2) of the APIs is already on Maven Central, so you can start using it right now.