Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use of javafx properties and binding in the data model

javafx properties are a great way to connect data-model to a javafx gui because their binding model implements a powerful notification-update mechanism.

Properties and bindings are not strictly gui-related, rather they're an extension to javabeans.

So one would like to use them in the application model classes without introducing a dependency on the package javafx.beans.property.StringProperty and in general from javafx.*.

In other words: (update)
I may need to split up the application into two modules.
One module should contain just classes that manipulate the data (the Model classes, MVC speaking).
A second module would contain all the graphical gui stuff, that is javafx.

If my data-classes use javafx binding, I would introduce an import javafx.beans.anything; (the best thing would be that bindings were part of java.* or javax.*, so i wouldn't reference a "gui library" into a core-data library). The fact that javafx will be included in stardard releases alleviate this prolbem, but it seems a tricky solution. Afterall I think I squint a web application that depends on some swing "utility" class.

Are there any options available?

I'm evaluating the effort required to create regular javabeans properties with listeneres and bridge them to fx properties.

like image 463
AgostinoX Avatar asked Sep 14 '12 08:09

AgostinoX


1 Answers

Binding of JavaFX object to POJO (Plain Old Java Object) techinque may help you here.

See next set of tutorials: http://ugate.wordpress.com/2012/06/06/javafx-pojo-bindings/

In two words you can use next way to access POJO objects:

    Person person = new Person();
    PathProperty prop = new PathProperty(
        person, "address.streetName", String.class);
    Bindings.bindBidirectional(prop, myTextField.textProperty());
    prop.set("123 1st Street");
like image 135
Sergey Grinev Avatar answered Sep 27 '22 22:09

Sergey Grinev