0

When establishing a binding with binding-builder, we can specify a converter to mediate between types such as using a String oriented TextField to work with a backing value of type Integer.

binder
.forField( this.phaseField )
.withConverter( 
    new StringToIntegerConverter( "Must enter an integer number" ) 
)
.bind( Panel::getPhase , Panel::setPhase ) ;

Is there some way to get/change/replace that converter later, after the binding is established?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • 1
    You just need to remove the Binding and then add it again with the new Converter. You can't just hot swap the Converter – Jay Jul 12 '18 at 08:11
  • You could also implement a wrapper/proxy converter that delegates to a another converter which can be exchanged then. – Steffen Harbich Jul 12 '18 at 10:42

1 Answers1

0

Per comments posted on the Question…

No

No, you cannot replace the Converter by itself.

Workarounds

A couple of possible workarounds:

  • Remove the binding, replacing it with a fresh Binder.Binding using your different Converter.
  • Implement the original Converter as a wrapper/proxy that delegates to another converter. Switch out that delegate as need be.
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154