Skip to main content

Welcome to Geoff Hayward's weblog.

During this coming Thursday's Edison Hackathon, at the FabLab, I am hoping to control a robot car by voice. In preparation I have made a JavaFX voice controller UI. And I have put together a 4-wheel drive robot car chassis kit.

The voice controller uses the IBM Watson Speech to Text service. Since recording the video below I have tried commands with context such as "turn left", "reverse the car ". This has had better results. Using phrases, I added regex (word matching) to pull out the commanding verb from the phrase. The commands are then sent a HTTP GET request to whatever IP address and port is given. The Edison will be on the car processing the GET requests via WIFI and acting upon them.

The video below is the running 4-wheel drive robot car chassis kit. To get it working I used an Arduino. I will, of course, swap the Arduino for the Edison before Thursday. The motors are powered by battery, I think the Edison will still be powered by mains (but I am going to seek advice on the day).

As you can see I am all set ready for the FabLab Edison Hackathon: very excited.

Go to post

This week's post is short; I ran out of time before the next session.

I last week's session we where given a 5 minute challenge. The challenge was to make an LED light up when a button is pressed down. Here is the outcome of the 5 minute challenge.

And here is the code I came up with during the challenge.

var groveSensor = require('jsupm_grove');

var button = new groveSensor.GroveButton(5); 
var led = new groveSensor.GroveLed(2); 

function doLight(){         


As you can see the button is plugged into D5 of the Seeed Base Shield. And the LED is plugged into D2. 'D' for digital.

In tonight's session we are going to be shown how to send data up to IBM's BlueMix. It going to be fun.

 Comments: 0 Tags:BlueMixEdison
Go to post

In last week's 2nd session of the Edison board class a lot of the time was spent making sure everyone was set-up ready to start making stuff. We were also introduced to the Grove Starter Kit Plus for the Intel IoT Edison Board.

The Grove Starter Kit Plus for the Edison Board is an interesting collection of sensors. The box includes many sensors, many LEDs, a buzzer, the base shield for Arduino and a stepper motor. Here is the full list of what's in the box:

  • Base Shield v2
  • Grove LCD RGB Backlight
  • Grove Buzzer
  • Grove Sound Sensor
  • Grove Touch Sensor
  • Grove Temperature
  • Grove Light Sensor
  • Grove Rotary Angle Sensor
  • Grove Button
  • Grove LED Socket with 3mm Red LED
  • Grove LED Socket with 3mm Green LED
  • Grove LED Socket with 3mm Blue LED
  • Grove 3-Axis Digital Accelerometer(±1.5g)
  • Grove Piezo Vibration Sensor
  • micro-USB cable

Our homework; get something working with the starter kit. I thought I would have a play with the LCD RGB backlight screen and the temperature sensor. This is what I made:

 Edison Board with the Grove Starter Kit set up to show the temperature on the screen.

The code that I wrote for this is:

I found the Seeed Wiki to be a very good resource for getting going with the sensor and LED RBG screen.

That's it for this week. The next session is tomorrow. I will have an update soon.

 Comments: 0 Tags:Edison
Go to post

Intel have announced that the Edison board now supports Java. This is good news for Java developers.

 Comments: 0 Tags:EdisonJava SE
Go to post

Last night I went along to the first session of the Edison board class that is being run by the local FabLab. This class will, hopefully, take me from a novice to a maker on the Edison board in six weeks. The class will end on a huge high as the final session is going to be a day's Hackathon. How awesome is that?

In last night's session two very knowledgeable and friendly volunteers, Ian and Simon, talk the class through the features of an Edison Board. They also showed us how to set-up a PC so that it can work with the Edison board.

The session began with an introduction to the features of the Edison board. The Edison boards features include:

  • Dual-core CPU
  • WiFi
  • Bluetooth 4.0
  • 1 GB DDR
  • 4 GB FLASH memory
  • Runs Yocto Linux

Ian and Simon also give us an idea of what the board and its features can do. An idea such as, controlling outside lights using the whereabouts of a connected GPS device.

Next we learnt about expansion boards. We learnt that there are several expansion boards for the Edison, such as the ones made by Sparkfun. And that you can create your own expansion board, if you plan to attach an Edison board to your own product. During this FabLab class we are using the Arduino Edison Kit (expansion board). Here, in the following video, is an overview of the Arduino Edison Kit we are using.

Once Ian and Simon had bought us up-to-speed on the Edison board and the Arduino kit's features they showed us how to connect them up. Just like in the un-boxing and assembly video from Intel (below).

Finally, we set-up the drivers on our laptops so that next week we can start coding and attaching sensors. Our homework, for the week, is to set-up the Edison Eclipse for C/C++ IDE, set-up the Arduino IDE, and to set-up the Intel XDK IDE.

Sadly, I don't think I am going to get to use Java with the Edison board for the time being. However, I can make do with C/C++ and or JavaScript. I think the idea behind installing the three IDEs is to let us try out the different ways to code for an Edison board.

If you are interested in how the class is going keep an eye out on this blog because, I am planning to add an update post after each of sessions.

While looking for the other two video's I found the 'step-by-step guide to windows' by Carlos Montesionos to be very good. So I thought I would add it to the end of this post.

 Comments: 0 Tags:EdisonFabLab
Go to post

JSF's h:outputStylesheet and h:outputScript elements have an odd way of ordering linked resources. For example if you do not set the target element of an h:outputScript to body the JavaScript is output before the CSS. This is irrespective of the order given in a template.

I needed to put an <!--[if lte IE 7]> [...] <![endif]--> element into a template. OmniFaces' o:conditionalComment is a great element for this; but the <!--[if lte IE 7]> [...] <![endif]--> condition was being output before the main CSS.

To fix this resource loading problem use a plain old HTML link elements instead of JSF h:outputStylesheet elements. Use this element with the HTML link elements having #{resource['libs:reset.css']} as there href.

<link rel="stylesheet" href="#{resource['libs:reset.css']}" />
<link rel="stylesheet" href="#{resource['css:login.css']}" />
<o:conditionalComment if="lte IE 7" >
     <link rel="stylesheet" href="#{resource['css:login-ie7.css']}" />

Will then output:

<link rel="stylesheet" href="/javax.faces.resource/reset.css?ln=libs" />
<link rel="stylesheet" href="/javax.faces.resource/login.css?ln=css" />
<!--[if lte IE 7]>
     <link rel="stylesheet" href="/javax.faces.resource/login-ie7.css?ln=css" />

Which is the desired resource ordering.

 Comments: 0 Tags:JSFOmniFaces
Go to post

Sometimes JSF does not have a component that will produce a particular type of HTML element. That's not a problem but, I always forget the three method deep route to the context path. I always find I have to work through an IDE's code completion tool to find the application's path.

Here it is for next time:


A shorter version:


Just for completeness here is the JSP version:


And finaly, the scriptlet version:

    String root = pageContext.getRequest().getServletContext().getContextPath();

If you know any more please do leave a comment.

 Comments: 0 Tags:JSFJSP
Go to post

JSF Facelets can store the returned value yielded from a call to an EJB. Doing so will mean the EJB does less work.

Let's say you are implementing a Facelet that will display a message stating something like 'No results' when a collection is empty. If the collection is not empty, the Facelet will call the EJB a second time. First to calculate the size of the collection; second to display the data in the collection etc.

Here is an example:


    <ui:fragment rendered="#{pages.all().size() == 0}" >
        <h:outputText value="No pages yet." />
    <ui:fragment rendered="#{pages.all().size() > 0}" >
        <h:dataTable value="#{pages.all()}" var="page">


In the example above the Facelet calls the EJB three times. First to calculate the size of the collection; second to display the elements the data table will occupy; third the data from the collection.

How to Store Values in JSF Facelets

The calling to the EJB can be reduced to just once per page render. Calling the backing bean using the ui:param JSF element will store the returned value in a variable.

   <ui:param name="pageSet" value="#{pages.all()}" />

Using the ui:param JSF element, here is an improved example:


      <ui:param name="pageSet" value="#{pages.all()}" />


    <ui:fragment rendered="#{pageSet.size() == 0}" >
        <h:outputText value="No pages yet." />
    <ui:fragment rendered="#{pageSet.size() > 0}" >
        <h:dataTable value="#{pageSet}" var="page">


I hope this helps.

 Comments: 0 Tags:EJBFaceletJSF
Go to post

I have been trying to put an older embedded Jetty served application onto Java 8. The application's JSP files where, however, not compiling. This delayed having the benefits Java 8 brings to development.

After a lot of digging I discovered that the Mavan 'org.mortbay.jetty' namespace (a.k.a. groupid) had been superseded by 'org.eclipse.jetty'. The newer development and fixes by the Jetty project are in the later namespace. Therefore, by replacing the old 'org.mortbay.jetty' dependency:


with the new 'org.eclipse.jetty'. dependency:


the JSP's compile and the older project now works with Java 8.

 Comments: 0 Tags:Java 8JettyJSPMaven
Go to post

Here are the photos I took at Devoxx Poland Java conference this year.


 Comments: 0 Tags:DevoxxJava EEJava SE
Go to post

This Sunday I am heading to Krakow to attend the 2015 Devoxx Poland Java conference. It's the first Devoxx in Poland. The conference has sold out all of its 2000 tickets. Wow, 2000 Java programmers in one place at one time. I can hardly wait. The conference commences on Monday and runs for three days.

I have planned out which talks I'm hoping to watch. Being keen on distributed computing, I am looking to go to most of the microservices talks. I would like to learn what's new in microservices (slash distributed computing), how it's being done nowadays, and what the current known pros, cons, issues and solutions are.

The conference has a few interesting looking talks on security too. I am hoping to go to the security talks. Being keen on RESTful web services, I would like to go to Erik Jan de Wit talk on OAuth2.

As well as the great content of the conference, I'm looking forward to the opportunity of chatting with other Java developers. Devoxx Poland here I come.

 Comments: 0 Tags:DevoxxJava EEJava SE
Go to post

Whilst fixing a defect in this blog's platform I realised that a particular business rule could be moved out of the code; into a database view. The movable business rule was "All posts returned to the front-end should have a published state". This rule extends to include a post's tags. That is "only the tags of a published post should appear in tag summaries".

One way to add this business rule would be to preform a WHERE published = true check in each respective query. The check would be executed by the database but is declared in the code. The declaration of the check is also in many places. I found it is particularly easy to forget to declare the check when joining tables. In the case of the tag summaries the check got over looked in a join between tags and posts.

Another way to add this rule to the platform would be to create a database view that encompasses the rule. Each query that has the aspect would then use the view. The business rule is then given once, declared and executed in the database. The join between tags and posts would then be:

FROM tags t
JOIN published_posts p

Where 'published_posts' is a database view; not a table.

 Comments: 0 Tags:Software Engineering
Go to post

Some context: I'v just been bug fixing a JavaFX 8 application. The application has a JavaFX ComboBox that lets a user select a file name from a list. When a selection is made the file is read into a TextBox. This functionality worked fine until a clear button's event was added to the same controller.

public void clear(ActionEvent event) {

When a JavaFX ComboBox is cleared with .getSelectionModel().clearSelection() the onAction events of the ComboBox is called. This makes it important to null check within the onAction event.

public void selected(ActionEvent event) {
    if (myCombobox.getValue() != null) {

To conclude: If the onAction event of a ComboBox uses the ComboBox's value within the event it pays to null check the ComboBox's value.

 Comments: 0 Tags:Java SEJavaFX 8
Go to post

After several weeks of programming a bespoke blogging platform it's finished. Well kind of finished. I will get to that. The blogging platform is for Web Developers, who need the back-end application part of a platform but do not wish to be tied to one language and template engine for their own front-end development work.

Why the need? I decided to create my new website with Java EE 7. I am a huge fan of Java EE 7 and JSF 2.2. The blogging platform is simply a by-product of that wish.

In the next iteration I intend to crate a REST API so that the front-end can be an authenticated REST client. Thus achieving the goal of language and template engine independence. In the meantime I'm road testing the blog platform with my own website. Once the next iteration is ready I will probably commit the platform to a public GitHub repository. You can find more information about the blog platform over at

Why the new website? My blogging goal has changed since creating the old website. I wish to have more of a weblog. The subject area of this new website will be anything Java EE, Software Development, and MSc study related. For convenience I have created an archive of my old posts. The Joomla ResponsiveMedia download can also be found there.

So here goes

Go to post