I am Benjamin Johnston, a researcher and a developer. I believe in the power of technology to improve our life at home, work and play. My passion is for using artificial intelligence and social robotics to create systems that bring joy and amazement.
When developing complex applications, JavaServer Faces (JSF) works best when used “statefully”.
In practice, this means using
@ViewScoped backing beans.
A consequence is that client-specific view state is persistent on the server.
JavaServer Faces can also be used in a stateless mode.
Unfortunately, stateless operation presents problems when using validation. In particular, validation failures prevent model update. This means that model state cannot be used to render a view in the event of a validation error.
Input components can use posted-back form data to re-render the view during a validation error.
However, output components (e.g.,
<h:outputText>) have no posted-back data.
Their state needs to be maintained using hidden fields in a form.
In JSF, hidden state can be maintained using
However, validation interferes with
Like any other input component, validation errors prevent all model updates.
My solution to this problem is to use a custom component.
The component works almost the same as
Instead of following the usual JSF lifecycle, it performs model update before validation.
Read on for the implementation and an example of its use.
Continue Reading (Published 6 September 2015)
Eleven years ago, I set up keyword alerts for “Prolog” on the major Australian career websites.
For ten years, there was no match. Until one-and-a-half years ago, when I reported a match on this blog.
I've just got another match. I believe that two Prolog jobs in 18 months counts as a boom in the Prolog job market!
Look out, Java. Look out, C#. Look out, Python. Prolog is taking over.
The advertisement disappeared quickly, but I took a few screen-grabs with my phone. I've stitched them back together below (and added the red circle).
Continue Reading (Published 29 July 2015)
In Sydney, it is possible to order a single loaf of bread from an “artisan” bakery for around $15. A fully featured Android smart phone or Windows Phone can be purchased for just over $30.
One smartphone for the price of two loaves of bread.
This smartphone price will, no doubt, come down. The bread prices will, no doubt, increase.
It won’t be long before a loaf of bread you order online will cost more than the computer you used to place the order.
(Published 3 July 2015)
The University of Technology, Sydney recently opened a new building (the ‘Broadway building’). It was created for the Faculty of Engineering and IT. It is wrapped in aluminium screens that are perforated with binary code. The university has a video about it on YouTube.
What do the screens say? How are they encoded? Read on for an explanation.
Continue Reading (Published 19 April 2015)
Visual Studio 2013 has several templates for creating new web projects. A brand new web project with authentication will have over 1500 lines of C# code. This saves a lot of time for new applications.
1500 lines for authentication may be too much if you’re learning ASP.NET. Fortunately, ASP.NET Identity is not too complicated when you start “from scratch”.
What follows is a short tutorial on setting up basic ASP.NET Identity in an empty web project.
Continue Reading (Published 28 March 2015)
This is a photograph of an Apple Newton that I noticed was lost/discarded in a park near my home today.
The hand-held computer is almost 20 years old. In fact, it might be regarded as a museum piece.
It doesn’t make sense to hold onto such a device for so long and then just discard it in the park.
I like to imagine it was owned by a die-hard Newton fanatic. Perhaps he or she felt that no modern smart phone or tablet could rival the classic. Thus, it was left in the park by accident.
For this reason, I left the Newton for their return. I can only hope that the original owner was joyfully reunited with their device.
(Published 8 March 2015)
This is a just-for-fun post. I’ll explore a C# implementation of a theoretical system called Lambda calculus.
It certainly isn’t practical. A calculation of the 25th Fibonacci number (75025) is not complex. An efficient algorithm can calculate it in just a few CPU cycles. A naïve recursive function can calculate it in 3 milliseconds. However, using Church numerals in a Lambda calculus takes 2300 times longer (7100 milliseconds).
The exercise may be pointless from a pragmatic perspective. However, it is interesting to see that the theory can be translated so directly into working C# code.
Continue Reading (Published 1 March 2015)
BunchOfFriends (formerly named FriendFace) is an intentionally insecure social network to teach web security. It was developed for Java EE 7 and a Derby/JavaDB or MySQL database. It has been tested on the GlassFish 4.1 app server. It is designed to have many of the OWASP Top 10 vulnerabilities.
Before deployment: Create a JDBC resource named “jdbc/aip” (without the quotes). On each deployment, the application will automatically (re)create database tables and pre-populate them with sample data.
Requirements: JavaDB or MySQL is required (for other databases, you'll need to modify SampleData.java). Java EE version 7 is required so you'll need GlassFish version 4.1 (or higher) or an equivalent application server. It should also work on GlassFish 4.0 if you upgrade GlassFish to use JSF/Mojarra version 2.2.2 or higher. One way to ensure these dependencies is to download the Java EE download bundle of Netbeans. In Netbeans, you can create JavaDB databases, launch GlassFish and open the domain admin console from the Services tab.
Purpose: I created the system while teaching a subject on advanced internet programming. It is intended to help teach a security mindset. Feel free to use it for any purpose. However, you should not deploy it on a publicly accessible server because it is so insecure.
BunchOfFriends is an alternative to the OWASP WebGoat project. WebGoat is tutorial oriented: it is a set of guided exercises. In contrast, BunchOfFriends is an ordinary application that is full of security holes.
BunchOfFriends can be used to re-create something like the “Samy” MySpace worm. You can create a profile that virally becomes friends with anybody who sees the profile name.
In the following is a discussion of how the OWASP Top 10 vulnerabilities relate to the application.
Continue Reading (Published 28 December 2014)
JavaServer Faces is a component-based MVC framework for Java web development. It is the “officially endorsed” web framework in Java EE 7.
JavaServer Faces applications have an unusual structure.
To explain, first consider the difference between using the iterator and visitor design patterns. Assume you want to sum the elements of a list. With an iterator, your code takes an active role. It would request (pull) each element of the list one-by-one. It would then update the total using each element it retrieves. In contrast, a visitor takes a more passive role. You would implement a visitor class that updates a total for every element it receives. The list is then responsible for passing (push) each element to the visitor.
What makes JavaServer Faces applications unique is that their controllers are typically very passive. The controllers in most other MVC frameworks are typically very active. They orchestrate most aspects of transforming inputs into a view. In contrast, in a JavaServer Faces application, the container does most of the orchestration. This inversion of control causes most JavaServer Faces applications to use a design pattern in which the application model is exposed as JavaBeans properties of the controller.
I teach a class on Java EE development. I try to relate design decisions to design patterns. However, I could not find any pattern catalog with a design pattern that resembles JavaServer Faces.
Continue Reading (Published 5 December 2014)
In 2005, on comp.lang.prolog, I claimed that Prolog is excellent for screen-scraping web-pages. Last week - almost decade later - I received an email asking, “Why?”
The internet never forgets!
My claim was based on Prolog’s powerful pattern matching features. In Prolog, pattern matching is referred to as unification.
Assume we have a variable called
Page whose value is as follows:
Page = html(body(h1('Sydney Weather'), p('Sunny')))
Then if we have a variable called
Forecast we can match it to a value using the following command:
html(body(_, p(Forecast))) = Page
Prolog will ‘unify’ both sides and output the result that
Forecast = 'Sunny'.
Pattern matching (or unification) is central to screen-scraping. In the remainder of this article I’ll show how to combine unification with a HTTP and HTML parser. I’ll then look briefly at the potential for natural language parsing.
Continue Reading (Published 31 May 2014)
I am currently teaching enterprise development with .NET.
I created this cheat sheet as a quick reference for ASP.NET MVC lab sessions. It includes Entity Framework, Validation, Razor and Controllers.
You might also find it useful.
(Published 16 May 2014)
I fear there is a public perception that robots are too "complicated". It is true that some problems are difficult. However, the basics are very accessible. It has never been easier to get started with robotics.
Programming a robot is literally as easy as creating a web-page.
I’ve recently been using the Sphero robot toy as a way to introduce people to robotics. Sphero works well with several technologies: Ubuntu, ROS, rosbridge, sphero_ros. These technologies make it easy to program complex robot behaviors. Because the technologies are standardized, the same programs can be used on other robots, including the PR2.
Continue Reading (Published 9 March 2014)
Should cars use sound instead of a dashboard?
Speedometer checks take attention away from the road. Audio could communicate the current speed without the driver needing to check the dashboard. It seems reasonable that, with audio feedback, a driver should spend less time looking away from the road.
I put this to the test and it turns out that, no, audio is distracting and annoying.
To prototype the idea, I purchased a Kiwi2 Bluetooth adapter made by PLX Devices. The device plugs into the On-board Diagnostics (“OBD-II”) socket found in virtually all cars made since 1996. The OBD-II standard is designed for technicians to check engine trouble codes as well as retrieve real-time engine performance data.
Continue Reading (Published 2 February 2014)
Prolog is one of my favorite programming languages. It is a very powerful language but has not had significant industry adoption (yet!).
Almost a decade ago, I set up keyword alerts for “Prolog” on the major career websites.
There is also a Project Management software system called Prolog. This resulted in many false alarms over the years. I hadn’t come across a single authentic advertisement in a decade...
... until this one (CareerOne, 5 January 2014):
I had to pinch myself to be sure I wasn’t dreaming.
(Published 1 February 2014)
In the photograph (by Srinivas Madhisetty), my software is giving Steve Wozniak a hug by a PR2 robot.
Continue Reading (Published 1 February 2014)
My homepage is a place where I can experiment with technology as I know the “client” is tech-savvy.
When designing the technical architecture behind this site, I had three objectives:
My solution is to use Markdown encapsulated in RFC822 messages.
Continue Reading (Published 26 January 2014)
I have decided to start a “blog”. I will use it to highlight my current projects. I will focus on projects that are experimental, incomplete, unsuccessful or ‘just-for-fun’.
Prior versions of my personal website have had ‘static’ designs. They made it difficult to add new content. My intention is that the informality of this format will allow me to share work wouldn’t suit publication elsewhere.
So, welcome! Feel free to let me know what you think!
(Published 25 January 2014)
Published 25 January 2014 by Benjamin Johnston.