quinta-feira, 21 de agosto de 2014

JavaEE, JavaFX and RFID - Part 4: The Client

Finally! It's the last post of the series about a JavaFX application that reads a RFID tag and talks to a JEE application that is in the "cloud".

Part 1: The Application
Part 2: Reading RFID from Java 
Part 3: REST API and Security
Part 4: The Client

The JavaFX application

This application aims to allow the user to input data from their RFID Tag and using a high level client(JAX-RS 2), access the data somewhere, which, in our case, is in Openshift.

The initial screen of our application

Application Structure

Basically we have FXMLs, for each FXML we have a controller that interacts with the PersonService class:

Brief explanation:
  • In model package we simply have simply Java that represent our business, in this case information about people, so we have a Person class.
  • *.fxml files are the view part of our application. These files can be opened in SceneBuilder for edition in a visual way. You can edit the fxml files directly as well...
  • FXMLs have a controller. The *Controller classes are responsible to handle user input and update the view with Person information;
  • Some basic styling was done using the appStyle.css file
  • The point of access to Person information is the PersonService class. It allow us to interact with the Person objects. We have two PersonService implementation: Mock and REST. The Mock represents a fake service, storing the data in memory, the REST service does the actual job of talking to Openshift to send and receive information using JAX-RS 2 client API
  • The rfid package contains the RFID pane, that when opened will wait the user pass a tag on the reader and tell our program the RFID of that tag;
  • AppTask is something I created to do a task, like query the server, and that the app is busy. I should have added a cancel button, but usually the REST client will send a timeout error if the server is not available; It has a Boolean property to indicate that the application is loading something and navigation binds this  property to an overlay progress indicator:

  • Finally we have the class AppNavigation that allow us to easily navigate between the application screens without having to spread FXML loads through the application. The main advantage of this class is that I can control the screens in a centralized point, so I could add later animation to the screen navigation and an overlay pane to shows a progress indicator while we are doing something.
That's basically it. The source code is on github and any suggestion is welcome.


Here's a short video with the app in action!


In these series the main goal was to have fun, the second was to show a PoC about using JavaFX and JEE technologies. Since this application had to access local resources(RFID reader), it makes sense to use JavaFX.
For future I want to run the client application on a raspberry pi with a touch screen!

Nenhum comentário:

Postar um comentário