May 18

I’ve asked this questions before, but this is a more elaborate view on it.

This is a burning question for me, because many of us have a data model already existing, particularly retrieved from some data source such as a database, XML files or binary formats, and now we want to leverage the power of JavaFX to impress our clients (and bosses).

There are a few issues here:

  • How do I notify about a property change? Just by saying the words, I go back to think about the JavaBeans technology and about the PropertyChangedEvent and Listener.
  • How do I get and set properties? Again, the JavaBeans standard comes to mind with the get and set method conventions we’ve come to know.
  • How do I create new Java objects? The easiest way would be to just have an empty constructor and allow for JSON-construction parameters to be passed using the setter methods. The problem here is how to allow creation of objects using factories, when sometimes necessary (such as with the JAXB framework).
  • How do I effortlessly implement binding and inverse capabilities in a regular Java class?

So we can have a few solutions to discuss:

  • Using the JavaBeans’ architecture for plugging beans into JavaFX.
  • Using only a set of the architecture, such as the set and get standard (used by most binding frameworks like Hibernate, JAXB etc) and the PropertyChangeEvent and PropertyChangeListener concepts and reimplement them, firing events as properties change.
  • Use some sort of aspect oriented programming concepts and attach our classes with annotations which would intercept changes to the properties and fire up the aforementioned events themselves.
  • Or what?

I’ve taken the liberty of adding a new entry to the JFX Wiki (it is a Wiki after all…) about this subject. I expect you all to go there and give a voice to this problem, as without any pluggability to regular Java data models, JavaFX is really just a Flash competitor, and not a new UI framework for Java.

Share
May 15

There’s a lot of talk ever since JavaFX was announced around why Groovy wasn’t enough and about the “conspirative Sun who never really liked Groovy anyway” trying to push it aside.

So first, I think no-one is trying to push anything aside. If someone ever heard the phrase “the best tool for the given task” they would understand it the best – Groovy is not the best tool for the task of UI design. Maybe JavaFX isn’t either at the moment, but at least that’s where it’s aiming, and Groovy just isn’t.

JavaFX comes with a few features that are extremely UI design specific, and I would like to reiterate them even though I’ve done this in previous posts.
Continue reading »

Share
May 15

Playing around with JavaFX and reading some more in the [scarce] documentation, I found the following neat tricks:

  • Expressions within quoted text: In JavaFX you can use variable and attribute names inside quoted strings, such as if you had a variable called name with the value “Aviad”, the following quoted string: "Name: {name}" would be parsed (and printed out if used as output) to be "Name: Aviad". The neat part is that expressions can be used inside the curly brackets, and even if .. then .. else constructs.
  • Automatic Nested Loops: In JavaFX you can create a nested loop by just specifying the second (or third or nth) loop in the for construct. Continue reading »
Share