The road to a fully encapsulated layered business model

About 20 years ago, during the time that I was working on my bachelor, I came in contact with a small company selling wall decorations. They had a need for some simple software, so I wrote a MSAccess application for them. During the years they grew and so did their software requirements, which resulted in a major overhaul about 10 years later when the whole code base was moved to Java 1.2 on top of an Informix database (back then considered a real competitor of Oracle’s RDBMS). The best way to access the database was using JDBC, so that was the approach that was chosen. Persistency frameworks were still immature (SDO) or expensive (Oracle’s Toplink).

The whole JDBC-combined-with-Swing did not work really well, partially because I had not figured Swing out when setting up the application’s architecture, but also because Swing uses objects and I had resultsets. Jumping forward another 5 years or so and persistency frameworks finally became an affordable foundation, so it was time to slowly migrate the code base over to Toplink (which soon was renamed to Eclipselink). Using Eclipselink made my Swing life that much easier, more than I expected, but also introduced new challenges.

reinders webshop
reinders webshop

Up until then, using JDBC in the 10 years old style, business logic was spread throughout the application screens. Initially this was a nuisance, but it could be dealt with. But soon, because of the growth of the company, it became a problem; there were additional interfaces required on top of the database for EDIFACT, website, webshop, email data exchange and support of mobile devices. The whole thing had grown into a full-fledged ERP and all these interfaces needed to make sure business rules were followed; it became clear that another approach was needed. (more…)

Continue ReadingThe road to a fully encapsulated layered business model

JavaFX 2.0, Swing 2.0?

At the beginning of my previous post I mentioned that I was stuck in the implementation of the calendar picker, because I was using one listener for 42 ToggleButtons, and I could not find out which of the 42 ToggleButtons was actually clicked. The code I have looks like this:

class Skin
	 * create the skin by using other controls
	private void createNodes()
		for (int i = 0; i < 6 * 7; i++)
			ToggleButton lToggleButton = new ToggleButton();
			lToggleButton.selectedProperty().addListener( iSelectedListener );

	// one listener for all 42 buttons
	final private InvalidationListener<Boolean> iSelectedListener = new InvalidationListener<Boolean>()
		@Override public void invalidated(ObservableValue<? extends Boolean> observableValue)
			// selected or deselected
			boolean lSelected = observableValue.getValue();

			// TODO: which ToggleButton was pressed?

After having dropped this at the JavaFX people I went into pause, assuming the InvalidationListener API would be extended to include the origin of the event (like Swing events do). After some time Richard Bair came back to me and explained that extending the API with a reference to the bean would mean additional bytes for each property. My initial reaction was; so??? It’s just a few bytes? But then I realized that JavaFX is not about controls, but about graphics; controls are just a subset in which I’m very interested, but the real focus of JavaFX is much more basic and raw. There will be applications with thousands of nodes, and then a few bytes per property quickly become megabytes and the rise of the mobile devices suddenly make memory important again. So it became clear that extending the InvalidationListener API is not wise indeed. (more…)

Continue ReadingJavaFX 2.0, Swing 2.0?

JavaFX 2.0 EA binding

After Swing, JavaFX 1.x and the iPad, now JavaFX 2.0 is candidate for the calendar picker shake down. Using MigLayout I’ve setup the basic day picking logic, but currently am stuck in build b21, because the events on the selected property in ToggleButton do not tell me which togglebutton was actually pressed, which is quite handy if you have 42 of them on screen. So I decided to focus a bit on binding instead.

My binding experience comes from JGoodies used in connecting Swing components to business model bean properties, usually using JGoodies’ BeanAdapter (which takes away the need to rebind every single property when the business model bean is changed underneath a Swing screen). Since I’m primary focussed on JavaFX’s controls at the moment, I wanted to see if I could bind my calendar picker to a business model. I’m also going to assume future 2.0 in which the properties on the business model also are using JavaFX properties. So I constructed a dummy business model with one property:

	class BusinessModelBean
		final public ObjectProperty iCalendarObjectProperty= new ObjectProperty();


Continue ReadingJavaFX 2.0 EA binding

Maven is the EJB2 of build tools

KnowledgePlaza has a rapid development platform called Cheyenne. Cheyenne is based on Java and produces in the end a WAR file, that can be run inside any servlet 2.5 / jsp 2.1 compatible container (like Tomcat 6). Cheyenne projects are build using Maven.

One of the features in the build is that there is the option of overlays; a Cheyenne project can be overlaid with other Cheyenne projects, who provide generic Java classes, JSP files, resources, etc. This feature is very similar to the overlay feature in the default WAR plugin, but Cheyenne has a few tweaks and differences that have forced us to write our own Maven plugin.

Initially the concept of Maven is very straight forward; there is a default build cycle consisting of about 20 steps (phases), and certain actions are bound to the phases based on the packaging type. For example: building JARs require different actions than building WARs. Simple? Simple. So in order to implement our tweaked build for Cheyenne all that needs to be done is write some custom actions and bind them to the build cycle. But there is this huge gap between theory and actually getting it to work. (more…)

Continue ReadingMaven is the EJB2 of build tools


In the continuing story of iPad development one of the issues that became obvious was that the UIDatePicker looked really lousy in the overall design of the hour entry application. The UIPickerView component that is used by UIDatePicker has a fixed skin that is hard to fit into another layout. This was mostly caused by the appearence it generates that it is a scroll wheel inside some kind of casing, but the casing has no outside border. So It really did not fit-in well.

Secondly the UIDatePicker takes up quite a bit of space on the screen but you cannot quickly pick another date in the same month; you have to scroll to it, possibly 30 days. I like the “normal” date pickers better. So I found the required excuse to write one.


Continue ReadingKPMiniPickerView

JavaFX 2.0 EA and MigLayout

  • Post category:JavajavafxUI

Oracle rebooted JavaFX and finally positioned it as what I for a long time have been longing for; Swing 2.0. Let’s not kid ourselves; JavaFX is a new UI library for Java, using the API lessons learned from Swing and taking it to the next level with animations and effects. The concept is powerful enough to even go into the 3rd dimension soon. And more importantly; JavaFX2 finally has a good integration (and therefor migration path) with Swing, so it actually has an existing user base which can easily be persuaded to take a peek. Not to mention the fact that it now uses Java instead of JavaFX script, so the EDI support is great right from the start. (Well done Oracle!) But if this doesn’t sound like Swing 2.0, I don’t know what will.

So what is JavaFX2 like? Well… I like it. The API is clean and intuitive. Since it uses a different approach, making everything from simple lines to complete tables just a node in a tree, it means that I still have to really get my head around that. Fact remains that this approach allows to easily add effects and animation on anything, being it on a square or complete screen (they’re all just nodes after all). But I know I will initially use JavaFX in existing Swing applications, so my primary interest is in the controls. In order to make my life easier, I decided that porting MigLayout could be a good idea.

I must say that the initial results in my opinion are not bad at all. Below is an example of a simple test involving a TextBox and Rectangle:

public class MigPaneTest1 extends Application {

    public static void main(String[] args) {
        Launcher.launch(MigPane.class, args);

	public void start(Stage stage) {

        // root
        MigPane lRoot = new MigPane(new LC(), new AC(), new AC());

        // add nodes
        lRoot.add(new TextBox(10), new CC());
        lRoot.add(new Rectangle(30,30, Color.YELLOW), new CC());

        // create scene
        Scene scene = new Scene(lRoot, 600, 300);

        // create stage

This results in the following layout:


Continue ReadingJavaFX 2.0 EA and MigLayout

Listen instead of delegate

  • Post category:iOS

One of the things that becomes obvious very fast is that iOS uses function pointers (selectors) or delegates to do callbacks. Usually iOS only allows one, meaning one pointer or one delegate. This is fine if you are the model to a table view or something, but in the case of events, history (read: Java) has proven that the listener approach is very effective. Since I am coding a number of components for iOS now, I really would like them to inform interested objects of what happened. For example when a date was picked in the calendar picker, or a year changed in the year mini picker. And I’m not going to code that again and again. Hence: KPListenerManager. (more…)

Continue ReadingListen instead of delegate

UIOverlayView – painting on top of your subviews

My first baby steps are becoming toddler steps and the first classes of a generic library are forming. I have found that making my infamous calendar picker part of my technology shake-down projects, usually forces me to code parts that are very educational. So by now there is a Swing version (JCalendarPicker), a JavaFX 1.3 version (FXCalendarPicker, part of JFXtras) and soon an iOS version (KPCalendarPicker). The Swing version actually was very straight forward. The JavaFX version required me to build a spinner component for the year and month selection. The iOS had the same requirements as JFX, because the default UIPickerView takes up way too much space on the screen to be used as a subcomponent for CalendarPicker. So I developed KPMiniPickerView which basically is UIPickerView on the scale of a text field.

KPMiniPicker has the looks of a text field, but I needed some way to visually make it different, so users know that it is not a text field. I decided to do this by painting blue arrows on top of the childeren, showing the direction in which the minipicker could be slided.


Continue ReadingUIOverlayView – painting on top of your subviews

First baby steps in iOS

Everyone seems to be developing iPhone / iPad applications lately. And let’s be honest; it’s great hardware. Long battery life, good UI, looks great. I must admit that I’m one of those “I don’t like the way Apple treats its customers and therefore I do not buy Apple” people. So I have a HTC phone, an Acer laptop, a Popcornhour media streamer, anything but Apple.

But recently someone asked me if I would be able to develop an iPad application and I had to say no. However, the fact is that business is still slow and that I’m still using my reserves frequently to make ends meet (living in a somewhat country side area doesn’t help my opportunities either). So I decided do a trial project for myself, just to see what iOS is like. Having done Objective-C somewhere in ancient history and remembering I liked it back then, was a good motivator, and I figured I would be able to pick it up fairly easily considering all of the programming languages I have coded. So I bought a book and spent a number of evenings reading through it, until I felt ready to give it a try.

I’m a strong believer in that every trail project should take on a real world situation, so you will be forced to tackle actual problems and not just the ones you think are interesting. We have a hour registration system we use internally and is used by a few of our customers. The main hour entry is done via an applet and I figured that would be an interesting test case; hour entry on the iPad / iPhone. It required me to do GUI and communicating with the back-end. (more…)

Continue ReadingFirst baby steps in iOS

About Oracle and Java

  • Post category:JavaOracle

You know, half the world is stumbling over each other trying to point out that Oracle is alienating the open source community from Java. And maybe they are, but until now, for me, it is still undecided.

Yes, Oracle did make Apache leave the JCP. But Apache was the one mixing the JDK7 specs with the fact that they wanted Harmony to be put through the JVM certification. I understand Apache, but I also understand Oracle for wanting to move forward. And for all the negative issues that people like to mention, Oracle also scored some points with me for getting Java on the Mac rolling again (they would score big time with Java on iOS, but that is a different matter and probably biased by my latest Objective-C experiences). And Google with Android, well, would the Android JVM pass the JVM certification? Most likely not, so legally it should not be called Java. And just like Microsoft wasn’t allowed to “abuse” Java many winters back, neither should Google.

For now Oracle is getting the benefit of the doubt, let’s see where they are taking it. The soup usually isn’t eaten as hot as it is served. [freely translated Dutch saying.]

That doesn’t mean that one should be oblivious to the negative points. What if Oracle is leaning too hard on the open source community and they are going elsewhere… Where would they go? DotNet? It’s not like Microsoft is much better than Oracle. PHP? Come on, PHP is just a scripting front-end for a bunch of Unix system libraries. It needs some serious growing up to be able to do full scale software development. Scala? Python? (more…)

Continue ReadingAbout Oracle and Java