This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

JavaFX and my Beagleboard xm

Inspired from the JavaOne Technical Keynote, I ordered a Beagleboard xm and all needed stuff like touch display, micro sd card, power supply and a nice looking case. I was fascinated from the features of the board and the JavaFX preview version for ARM - and it is not really expensive, of course it costs more than the Raspberry Pi (btw the Raspi will be my next project).

I developed different applications with GSM modems, push buttons (buzzers) - connected to RS232 - in the past, with desktop hardware. The applications were written in Java and used rxtx heavily. So I thought that it would be a good start to test my old applications or the RS232 communication with my new board. The next step could be a modern JavaFX UI for my old applications.

That was the idea... but first it was important to build/create the SD card for the board. I had different options because Oracle published a document about the creation of their image and Gerrit Grunwald created his own image based on the documentation. He published his files and it was possible to use his image.

I decided to build my own image because I love to hack with linux, I wanted to understand the build process and I did not want to miss the experience. To be honest, the documentation was so short and simple and I thought it should be very easy :)

Well, I won't post all steps for the creation of my image, instead I'll post my problems with the original guide and the differences. Start with this documentation and go to the chapter Rebuilding Ångström 12.05.

I loaded Ubuntu 12.04.1 LTS Desktop and installed it in a fresh VirtualBox VM (30G disk image is enough, but 40G is better). The installation was not very special, only standard packages. After the installation I did:

apt-get update
apt-get upgrade

I continued with the installation of important tools, as described in the documentation, but don't forget the package gawk and please install ia32-libs-multiarch. The next steps from the documentation worked like a charm... but I had some smaller problems with my proxy. The configuration was not the problem because documentation mentions proxy setup. I'm not sure if the cause of the problem was the old squid version or an old configuration file. In order to use git through my proxy, I had to allow CONNECT to port 9418:

//new
acl git_port port 9418

//new
http_access allow CONNECT git_port
//existing
http_access deny CONNECT !SSL_ports

In my environment the http URL did not work, so I switched to https and git clone worked. During the build I had two problems. The first was a manual cancel of the build process because I pressed the wrong keys. But it was no problem to start the build again because it continued (standard make behaviour) and did not restart the whole build. The other problem was with XML parsing (xmlto/xmlling failed with docbook... fetch). The problem was gone after some experiments... I am not sure what exactly solved the problem because I installed the docbook-utils again and restarted my VM and afterwards the build continued without errors?

The Oracle documentation contains the info that the build process "takes several hours to run". In my case and with my environment, the whole build process took about 24 hours ;-)

After successful creation of the SD card, it was time to power up the board. I did not attach a serial console and was a little bit unsure what happened, because my screen (standard LCD 19" without touch) only showed a beagleboard image, but hurray the first start was faster than described - about 10 minutes (class 10 SD Card, 8G) - and gnome started automatically.

I continued with JDK + examples installation and verified that everything worked - and it did!

One problem was that gnome was not repainted after I stopped a JavaFX application, but maybe I should not use gnome together with JavaFX (I read this anywhere, but can't remember).

The documentation describes that you must restart the Beagleboard xm because it is not possible to close the OGLES2Water demo... C'mon it's linux. If you have no better ideas, simply kill the OGLES2Water process and gnome and restart gnome. That's it.

If you are working on a windows machine, I recommend winscp for file transfers, to the board, because it is a GUI for scp. I love using vi and know ALL shortcuts (believe me ;-) ) and it is a really great tool but sometimes it is easier to use "modern" tools like midnight commander. So I installed mc:

opkg update
opkg install mc

I think it's easier and you are faster with mc compared to the console.

After everything worked - it was time to test the serial input with some source code.

The beagleboard has a RS232 interface and I thought I could use it without problems - bad idea.
I started with the installation of rxtx:

opkg install rxtx
opkg install librxtx-java

(Add /usr/share/java/RXTXcomm.jar to your classpath and /var/lib/jni in your java.library.path)

After the installation, I used my existing serial interface java implementation and started my tests and had following problems:

  • rxtx did not find serial interfaces
  • the device name was /dev/ttyO2 and not /dev/ttyS0
  • dmesg|grep tty showed that /deb/ttyO2 was already in use

Fixed first problems with an additional system property:

-Dgnu.io.rxtx.SerialPorts=/dev/ttyO0:/dev/ttyO1:/dev/ttyO2:/dev/ttyO3

and set console="" in my uEnv.txt to solve the last problem. I didn't need a serial console!

The next problem was that my buzzer test application did not work because the RS232 received "no signals". I tried to find out why and found the "problem". The standard RS232 header on Beagleboard xm only supports RX, TX, GND (send and receive data) and all other pins are ignored or not connected. Read the documentation (BEAGLE-xM_SRM_REV_C_1_0.pdf, page 102) for the details.

So, I connected an USB to serial adapter and removed the manual serial port configuration for my application because /dev/ttyUSB0 was detected automatically. After a restart of my application, everything worked as expected.

Now I'm ready for a JavaFX application :)

JavaFX + Beagleboard in Action (NightHacking)

See JavaFX on a Beagleboard in Action:

NightHacking/ tour

A nice application.

Joomla/RSForms post request to Java Servlet

Maybe this information is useful for other Joomla/RSForms users or for developers who want send a post request from php to anywhere :)

I had the following configuration in my dev environment:

Joomla together with RSForms (free version)

I love to use this combination because it is easy and just works. With RSForms I created some forms like User registration. This tool allows you to send emails to the registered user and it stores the registration automatically in the database. It's really useful.

In my case, the user registration was not real-time because I got an email and had to create a user account manually. This is web 0.1.

Well, I decided to push the whole process to web 2012. My plan was to create a simple Java servlet that creates my user accounts. This servlet should be called from the RSForms component, with a simple POST request. I don't like SOAP overhead, so it was no option for me. Of course, my servlet is a service :)

BTW, I wouldn't change the RSForms component because it should work as it was. The component has a nice feature that allows you to configure custom scripts for loading and processing.

I started with the configuration and added following process script:

$url = 'https://tomcatvm/services/User';
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$data = array();
$data[] = 'language=en';

foreach ($_POST['form'] as $post => $value)
{
    if (is_array($value))
    {
        foreach ($value as $post2 => $value2)
        {
            $data[] = $post.'[]='.urlencode($value2);
        }
    }
    else
    {
        $data[] = $post.'='.urlencode($value);
    }
}

curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $data));
 
$data = curl_exec($ch);

if (curl_errno($ch))
{
    JUtility::sendMail($form->emailfrom,$form->emailfromname,
    'support@sibvisions.com','Service error',
    'Service call failed! ('.curl_error($ch).')',$form->emailmode,null,null,null);
}

curl_close($ch);

The code is written in php, but it is not rocket science. It simply sends a post request to the configured URL. The important thing is that all form parameters were used as parameters for the request, because the service needs the entered values!

That's all for Joomla/RSForms. During development I thought that the process script will be executed only once per form but that was not true. It was executed after loading and everytime when the user submits the form. If the forms had validation errors, the process script was executed more than once (with and without valid inputs).

I changed the php script a little bit and moved the process execution after the validation. It depends on your RSForms version, but in my case the original script (/plugins/content/mosforme.php) looks like:

...
eval($form->script_process);

if(!empty($processform)){
...

and the new script:

if(!empty($processform)){
...
    if(!empty($_SESSION['formmsg'])){
    ...
    // store it in the db
    ...
    eval($form->script_process);
    ....
}

But it is also possible to use the original script without modification.

The other side was the servlet... It's to simple to show you the whole source, only a snippet:

@Override
public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException
{
    String sParamFirstName;
    String sParamLastName;
    String sParamEmail;

    try
    {
        sParamFirstName = getParameter(pRequest, "firstname");
        sParamLastName  = getParameter(pRequest, "lastname");
        sParamEmail     = getParameter(pRequest, "email");
        sParamLanguage  = getParameter(pRequest, "language");
    ...

Start with JavaFX embedded

Some useful links if you plan to start some experiments with JavaFX for embedded devices like Raspberry Pi or BeagleBoard-xM:

And finally, a very useful and detailed howto from Gerrit Grunwald: Who let the dogs out

JavaFX TableView with Database records

JavaFX has a nice looking TableView and it offers useful functionality, but the standard implementation is not useful for real-world database applications.

Why?

  • You must fill a TableView manually with records from the database, because JavaFX has no datasource support integrated. This means you have to use JDBC directly or libraries like EclipseLink or Hibernate, to fill your table.
  • If you fill your TableView manually, you miss support for database sort operations. JavaFX supports memory sort but if you have millions of records, it is not the best idea to fetch all records for simple sort operations.
  • Support for lazy-loading/load-on-demand is not integrated. With load-on-demand, I mean the possibility to load records when the UI requests them. If you have a database table with e.g. 10 million records, the UI should load the first 1.000 (or more). If the user needs more records, the TableView should load more automatically. I won't use paging for this use case.
  • Column resizing works well but is not user-friendly. The CONSTRAINED_RESIZE_POLICY is like auto-resize in JTable. It allows column resizing within the table width, but it is not possible to enlarge the table horizontally. The UNCONSTRAINED_RESIZE_POLICY allows enlarging but adds an extra "column". This column is not selectable and fills the gap if the total column width is smaller than the table width. We need a resize policy that supports both and such a policy is not included in JavaFX.
  • The default selection model offers ROW and CELL selection, but in ROW mode you don't see the selected cell (= focus). If you need an editable TableView it is a problem if you can't see the selected cell.
  • If you need an editable table, you have support but not a working solution - especially if you work with database records.
  • Missing support for Insert and Delete rows with keyboard. It is possible to start updating values with <F2>.
  • No standardized solution for Master/Detail with multiple levels.

I don't say that it is not possible to implement above features, but if you don't create a custom control, you'll have a lot of boilerplate code in your applications. Some features are not trivial because the APIs do not offer relevant methods and the JavaFX control development model hides a lot of functionality. Of course, it is always possible to create new controls, but it is not cool to reinvent the wheel. One problem is that the TableView implementation together with the TableViewSkin and TableViewBehavior are not very developer friendly, because the classes are not really extendable. Most important methods are private or final. Another problem is that you need css and code together, for specific features. It is easy to change padding with css but where is a method in the API?

A solution for the datasource problem is offered from the DataFX project.

I'm a developer for business application frameworks and most applications are connected to databases with or without an application server. The applications must be fast and responsive. It helps if an application looks fancy, but functionality is more important.

Sometimes I think that JavaFX controls are really impressive but their developers should create real-world (business) applications.
If you get feedback from your paying customers you know exactly what you have to do and which features are good and important. My personal opinion is that Oracle should ask application developers and work with them to solve real-world problems.

With JVx, we have a full-stack-application framework that solves our business problems and we try to implement new UI technologies as soon as they are market relevant. So we started with the integration of JavaFX. We tried to solve above points, because they are very important for us.

Our current development progress is available as OpenSource (sub)Project of JVx and is licensed under Apache 2.0.

What we have solved so far?

All above points, but more or less clean. Some solutions are "dirty" because we have no API or didn't find a better solution.

"Dirty" solutions?

  • Column resize policies are supported but relevant features are missing or hidden, e.g. The TableView retrieves the content-width from the TableViewSkin (via general control properties - getProperties()) because the TableView has no access to scrollbars and the content width is different with and without vertical scrollbar. This is dirty and does not work in any cases in the original TableView, but this information is important if you develop your own resize policy! We need more and better access through the API.
  • Load-on-demand works but this is the dirtiest hack. It is not so easy to add a feature that was not planned. We used a custom event dispatcher to made it possible. We must check the implementation with every TableView update...
  • Show focused cell in ROW selection mode is possible with CSS but it is horrible.

There are more funny solutions, but the result just works. One additional and maybe interesting feature is, that we don't change the row height if you start editing. It was annoying that the table height toggled in edit mode.

Our current solution offers an editable TableView which is connected to a database (2 or 3-tier architecture). All sort operations are delegated to the database. The solution supports any Master/Detail relations (memory, db and mixed) and loads records automatically from the database. All Insert/Update/Delete operations are sent to the database.

Our current solution is not finished because we don't have specific cell editors. We have to implement cell editors for Number/Date/Images/LOVs (= ComboBox).

A first impression:

TableView with Database

TableView with Database

  Country - States - Districts

with Master/Detail/Detail

The database:

CREATE TABLE COUNTRIES
(
  ID      INTEGER IDENTITY,
  COUNTRY VARCHAR(200) NOT NULL,
  EU      CHAR(1) DEFAULT 'N' NOT NULL,
  constraint CTRY_UK UNIQUE (COUNTRY)
)

CREATE TABLE STATES
(
  ID      INTEGER IDENTITY,
  CTRY_ID INTEGER NOT NULL,
  STATE   VARCHAR(200) NOT NULL,
  constraint STAT_UK UNIQUE (STATE),
  constraint STAT_CTRY_ID_FK FOREIGN KEY (CTRY_ID) REFERENCES COUNTRIES (ID)
)

CREATE TABLE DISTRICTS
(
  ID       INTEGER IDENTITY,
  STAT_ID  INTEGER NOT NULL,
  DISTRICT VARCHAR(200),
  constraint DIST_UK UNIQUE (DISTRICT),
  constraint DIST_STAT_ID_FK FOREIGN KEY (STAT_ID) REFERENCES STATES (ID)
)

Flyspray integration in Testlink

We use Testlink as Test Management Tool for our customers. It has a lot of integrations for bug tracking systems, but Flyspray was missing. We use Flyspray as bug tracking system and it was important that it is integrated in Testlink. So we decided to implement the integration.

It was very simple to integrate Flyspray because the API of Testlink has nice support for additional systems.

If you are interested in our integration, please contact us. The source code is licensed under Apache 2.0.

Some impressions:

Assigned Bug

Assigned Bug

 
Assign Bug

Assign Bug

JavaOne 2012 Session

JavaOne 2012

JavaOne 2012

 

Our JavaOne session was on Wednesday, Oct 3, 3:00 pm to 4:00 pm together with Allan Gregersen and Geertjan Wielenga. All details about the Session (presentation, video, downloads) are available here.

We talked about dynamic class reloading with Javeleon and used VisionX for our demonstrations because it was a great use case for Javeleon.

The slides are also available here.

After our Session, we had a great time at the appreciation concert. Oracle did a great job and organized a perfect concert. Here is our favourite picture from the stage.

Concert

Appreciation Concert

Oracle Forms' best friends...

...should be JVx and VisionX.

Our integration of JVx applications is now available.
We won't replace Forms with Java and don't say that Java is better than Forms. Of course, Forms is not dead and it will probably never die. But, Forms uses Java as client technology and why shouldn't we bring more Java to Forms?

If you search for Java and Forms all you will find are relatively simple components or PJCs, e.g. a JTable integration in your forms module. There are a lot of "ready-to-use" examples, but if you are not a Java pro, it will be hard to understand what happens.

I know that Forms needs a face lifting, but it is not a good idea to start from scratch. You should start pimpin' with some cool icons, colors and a nice background image. But if you need better usability, don't try to reinvent the wheel. You need more than modern controls like a JTable with sort-on-header. Do you know how you fill your table with data or how you transfer data from a remote database to your application within a 3-tier architecture?

What you need is a framework that is as powerful as forms, offers modern controls and solves communication problems. And it must be simple - should just work, because Forms simply works.
Oh... I forgot that the framework must work in Oracle Forms and without Forms. It must be a one-4-all solution.

If you think that this is impossible then you are wrong, because it works!

We married best of both worlds.

  • Use a modern table in your forms application and don't think about how you connect the table to your database. You get table headers and sort-on-header for free :)
  • Use layout managers for dynamic GUIs instead of fixed size GUIs.
  • Call a stored procedure on button click within your Java bean? No problem.
  • Use modern Look and Feels and pimp your forms GUI.
  • You need REST services? They are already implemented.

And you don't need different frameworks or tons of libraries. You need exactly one framework - JVx. It solves all your problems and with our Forms integration, it is possible to use your Java application within your Forms application without code changes.

We have some screenshots for you :)

Forms application with Java screen   Java screen without Forms

On the left side, you see the Forms application with exactly the same screens as in our Java application on the right side. We added a close button to the forms application, because it is Forms and you decide when you need Java and when standard Forms controls are better.

Oh... when you think you must migrate your Forms application to another technology - why do you think that? Modernize your existing Forms applications and if you decide to replace Forms, your Java screens are ready.

JVx beta releases?

Some of you asked me why no new beta releases are available.

The answer is that we don't build beta versions since we have our nightly builds. It is better to "release" daily instead of monthly. You get access to the latest features with the delay of one day.

You can download the nightly builds from here.

Flyspray as Ticket/Support System

Every (open source) software project needs a tool for bug reporting. Without such a tool it is hard because you need spreadsheets or mailing lists to manage todos. I think every developer knows why such tools are used ;-)

There are a lot of bug reporting tools like Bugzilla, JIRA, trac, Mantis, ... There are also a lot of project management tools with built-in ticket systems like Redmine.
It depends on your needs, if you develop open source or commercial software, the available money, ... which system is best suited.

We evaluated some systems and decided us for Flyspray.

Why?

We need a bug tracker that

  • is also a change request management tool
  • should be used from our customers (end-users)
  • should not have tons of configuration options
  • should be commercially useable
  • should be open source
  • should be easily adaptable
  • should allow custom styles/themes
  • should be template based
  • should not waste development time

Many points have been met from different tools, but the popular tools were too complex or heavy weight. Flyspray is different, because it focuses on the basics. One of the problems are custom styles/themes. It supports custom themes but it does not support custom site templates.
But it offers most features that a professional system should have, it is small and easily adaptable - compared to other tools. And the tool is not only for developers. An end-user can handle it.

We knew that the system needs some tweaks. We added support for

  • custom site templates (per project)
  • custom mail templates (text, html, ..)
  • enter officer for a ticket (group setting related), add effort (per ticket, per comment), add internal comments
  • added a switch that disables global priorities/severities,status, ...
  • set severity colors via database per project (instead of css)

This are some of our changes. We also fixed some layouting problems and created custom themes/templates.

If you are interested, look at our Flyspray installation:

SIB Visions Theme:
https://oss.sibvisions.com

Different style/site templates:
https://oss.sibvisions.com/index.php (WebUI)

If you are interested, leave a comment.