Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6, 1.6.1, 1.7-beta-1
-
None
Description
This should work, but doesn't
SwingBuilder swing = new SwingBuilder() def model = new BindableBean() def isInteger = { v -> try { Float.parseFloat(v) return true } catch (NumberFormatException ignore) { return false } } swing.actions { frame( title: "Binding test", size: [100,60]) { textField( id: "t1", text: bind(target:model, value:'123', targetProperty: "value", validator: isInteger, converter: Integer.&parseInt) ) } } assert model.value == 123 swing.t1.text = '1234' assert model.value == 1234 swing.t1.text = 'Bogus' assert model.value == 1234 swing.t1.text = '12345' assert model.value == 12345
The issue is that the validator is called without the source value, making the validator blind to values and quite useless