Binding Java classes to JavaFX elements
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
getandsetmethod 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 andinversecapabilities in a regular Java class?
- Using the JavaBeans' architecture for plugging beans into JavaFX.
- Using only a set of the architecture, such as the
setandgetstandard (used by most binding frameworks like Hibernate, JAXB etc) and thePropertyChangeEventandPropertyChangeListenerconcepts 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?