Possible additions to JavaFX to facilitate forms and validations
Knut Arne Vedaa
knut.arne.vedaa at broadpark.no
Tue Dec 6 08:57:22 PST 2011
On 06.12.2011 17:14, Richard Bair wrote:
> Oh, I just had a crazy idea. What if we just reused WritableValue?
Have value holding controls implement WritableValue. Hmmm.
That's not so crazy. Actually, I proposed it in the forum thread. :)
(Ok, I proposed ObservableValue.)
There's a set of interfaces that may be considered for this.
The simplest would be Observable. That gives you add/remove listener.
Since these are not parameterized, you could have a List<Control> and
call them on each item.
Next up is ObservableValue/WritableValue, which gives you
getValue/+setValue.
Since these are parameterized, you won't be able to iterate through a
List<Control<T>> and use them on each item without casting; could be
useful still.
Lastly, Property, which gives you the binding methods as well.
In that case, i.e. class Control<T> implements Property<T>, the control
would *be* the property for the value it holds, i.e. instead of
textField.textProperty.bind(someObservable) you could do
textField.bind(someObservable). The actual methods could just could be
proxies to the control-specific value property.
(This is what would be compatible with zonski's original proposal.)
I'm not sure how much it gives though, since most controls will hold
different datatypes so you can't really abstract over them.
Just some quick thoughts.
Knut Arne
More information about the openjfx-dev
mailing list