• Home
  • RSS Feed
  • Log in

Mark Bakker

Review Java EE6 and JavaFX 1.3 – Part II, the front-end
Posted by Mark Bakker in the early morning: June 1st, 2010

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.

Share

Filed under Java | 5 Comments »



5 Responses to “Review Java EE6 and JavaFX 1.3 – Part II, the front-end”



    Karan Nangru Says:
    Posted at: June 1, 2010 at 7:50 am

    Your conclusion’s comparing Flex with Flex. I suppose your not in favour of JavaFX as compared to Flex. Well same here.
    Ought to mention that there many components such as datagrids , trees, sf that are not there in FX. You’ll have to load the usual swing component in FX for tress and stuff – which requires extensive swing + FX handling and would thus consume much more effort…..

    Reply


    Kenneth Says:
    Posted at: June 1, 2010 at 8:52 am

    Thanks for pointing out what I’ve been worrying about JavaFX.
    After few weeks of evaluation I also conclude JavaFX is not ready
    to develop serious business application.

    Reply


    zilti Says:
    Posted at: June 1, 2010 at 12:23 pm

    What about using Apache Pivot if you need complex GUI elements?

    Reply


    William Antônio Siqueira Says:
    Posted at: June 1, 2010 at 7:08 pm

    Hello,

    For a table view, there’s three solutions:

    1 – JFXtras TableView
    2 – Rakesh Menon Table View: http://rakeshmenonp.wordpress.com/2010/05/22/javafx-1-3-%E2%80%93-tableview/
    3 – Bind to a JTable, from Java Swing.

    Reply


    Albert Says:
    Posted at: June 3, 2010 at 7:24 am

    It would be interesting to compare it with a jQuery/html solution. That might be even easier then javaFX/Flex… What do you think??

    Reply


Leave a Reply

Click here to cancel reply.


Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India
  • XebiCon 2012

Categories

  • Java (312)
  • Agile (192)
  • General (141)
  • Scrum (70)
  • Testing (65)
  • Architecture (65)
  • Performance (47)
  • Middleware (59)
    • Deployment (40)
  • Xebia Labs (41)
  • SOA (31)
  • Project Management (31)
  • Podcast (31)
  • Tools (28)
  • Uncategorized (24)
  • lean architecture (20)
  • Quality Assurance (19)
  • Articles (15)
  • Requirements Management (14)
  • Virtualization (21)

Tag Cloud

    Oracle Java JPA implementation patterns lean architecture Moving to India Agile XML Spring Hibernate Frameworks Javascript Xebia lean architectuur JPA agile architectuur Scala Architecture product owner Concurrency Control Grails Flex Eclipse Ajax Scrum Maven ACT Groovy SOA Lean TDD

Archives

  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
Avatars by Sterling Adventures