Summary
In the first part of this review (the JavaEE6 back-end) I created a small application which is a JSON REST service to be used as back-end for a JavaFX front-end.
This second part of my review covers a small review of JavaFX, to see if it meats my requirements as front-end for my personal finance application (see previous post).

My conclusion for now is that JavaFX is an interesting new technology, I think it can be used for small applications or forms (think about internet adds). But for serious applications it is not ready yet.
I am really missing Datagrids, the way you have to deal with Session cookies for the Rest service is far to low level. I hope someone can point me to a place where I can find better solutions for those problems (if there are).

Requirements
The basic functional and technical requirements I described in my previous post, but the most important requirements for the front end are:

  • Have an tree data table (in Flex it is called an advanced datagrid) for visualizing an hierarchical data structure.
  • Be able to show adds in the front-end to be able to earn the costs of the hosting.

The back-end service
The service I used in this review is an simple service for which I have to logon via Basic Authentication an can get User information (username) via an Rest call.

The javaFX client
First I created a new FavaFX project and added some fields to the form.
pf_client1

After this I created some code to do the login action and show the username.  (FYI: I now that this is no good OO-design but for this small test it is the best way to show it.)

public class User {

    var sessionCookie: String;
    var username: String;
}
var user: User = User {};

public class Main {
    // <editor-fold defaultstate="collapsed" desc="Generated Code">

    var userJsonInput;
    var userParser = PullParser {
                documentType: PullParser.JSON;
                input: bind userJsonInput;
                onEvent: function (event: Event) { // parse the JSON user data and populate the user object
                    if (event.type == PullParser.END_VALUE) {
                        if (event.name == "username") {
                            user.username = event.text;
                        }
                    }
                }
            }

    //todo make this a function to add the headers! Make ik possible to logout/ relogin
    function buttonOnMouseClicked(event: javafx.scene.input.MouseEvent): Void {
        var httpHeader = HttpHeader.basicAuth(usernameTextbox.text, passwordTextbox.text);
        var sessionHeader = HttpHeader {
            name: "cookie"
            value: user.sessionCookie
        };

        def request: HttpRequest = HttpRequest {
            location: "http://localhost:8080/pfserver/services/private/account/show";
            headers: [ httpHeader,sessionHeader ]
            onInput: function(input: java.io.InputStream) {
                userJsonInput = input;
                userParser.parse();
                if(request.getResponseHeaderValue("set-cookie") != null){
                    user.sessionCookie = request.getResponseHeaderValue("set-cookie");
                }

           }
           onException: function(ex: java.lang.Exception) {
              println("onException - exception: {ex.getClass()} {ex.getMessage()}");
          }
        }
        request.start();

    }
}

The first thing you see is the PullParser, this parser is an parser for JSON data. I fetched the event of an new field an added this to a global value (ugly, I know :-)).
Using this was quite simple, but in my opinion to low level for big JSON data structures.
Getting the data is done with the HttpRequest, searching for this function did costs me 30 minutes because this is changed in each new version of JavaFX. First there was some async package for this, but now we only have the HttpRequest. Using the HttpRequest was not complex but this time again to complex for big applications, simple things as a cookieManager are missing, of course I can write one myself, but this type of things will cost me to much time if I compare it to Flex.

The first requirement, having a tree data table is also not met, even a simple data table does not exists for now.

Conclusion
I will not use the current version of Flex for my new front-end. It's to low level at the moment compared to Flex. It is slowly getting there if I compare it to previous releases but it still has a long way to go.