FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
If I create a single step binding via Bindings.select, e.g. Bindings.select(a, "b"), then modifications of member a.b are not propagated to the binding. As a consequence, the binding is neither invalidated nor updated when binding.getValue() is called.
However, multi step bindings (a.b.c) work as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create and run the JUnit test posted in the "source code for an executable test case" below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All three unit test cases complete successfully.
ACTUAL -
The following test case fails: testBindings_select_MenuItem_text
Failure: org.junit.ComparisonFailure: expected:<item[_changed]> but was:<item[]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at PropertyBindingTest.testBindings_select_MenuItem_text(PropertyBindingTest.java:27)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.StringBinding;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
public class PropertyBindingTest {
private Menu menu = new Menu("menu");
private MenuItem item = new MenuItem("item");
@Before
public void setUp() {
menu.getItems().add(item);
}
@Test
public void testBindings_select_MenuItem_text() {
StringBinding binding = Bindings.selectString(item, "text");
assertEquals("item", binding.getValue());
item.setText("item_changed");
assertEquals("item_changed", binding.getValue());
}
@Test
public void testBindings_select_MenuItem_parentMenu_text() {
StringBinding binding = Bindings.selectString(item, "parentMenu", "text");
assertEquals("menu", binding.getValue());
menu.setText("menu_changed");
assertEquals("menu_changed", binding.getValue());
}
}
---------- END SOURCE ----------
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
If I create a single step binding via Bindings.select, e.g. Bindings.select(a, "b"), then modifications of member a.b are not propagated to the binding. As a consequence, the binding is neither invalidated nor updated when binding.getValue() is called.
However, multi step bindings (a.b.c) work as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create and run the JUnit test posted in the "source code for an executable test case" below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All three unit test cases complete successfully.
ACTUAL -
The following test case fails: testBindings_select_MenuItem_text
Failure: org.junit.ComparisonFailure: expected:<item[_changed]> but was:<item[]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at PropertyBindingTest.testBindings_select_MenuItem_text(PropertyBindingTest.java:27)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.StringBinding;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
public class PropertyBindingTest {
private Menu menu = new Menu("menu");
private MenuItem item = new MenuItem("item");
@Before
public void setUp() {
menu.getItems().add(item);
}
@Test
public void testBindings_select_MenuItem_text() {
StringBinding binding = Bindings.selectString(item, "text");
assertEquals("item", binding.getValue());
item.setText("item_changed");
assertEquals("item_changed", binding.getValue());
}
@Test
public void testBindings_select_MenuItem_parentMenu_text() {
StringBinding binding = Bindings.selectString(item, "parentMenu", "text");
assertEquals("menu", binding.getValue());
menu.setText("menu_changed");
assertEquals("menu_changed", binding.getValue());
}
}
---------- END SOURCE ----------