Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114429

TableColumn/PropertyReference: binding readable property must not require getter

    XMLWordPrintable

    Details

      Description

      reported in
      http://forums.oracle.com/forums/thread.jspa?threadID=2251730&tstart=0

      I'm aware of RT-14927, so exact target location of this issue probably will change (as property() will be removed from the TableColumn api) but some api of binding by property name will be available (will it? fearing the worst ...) and then this issue is the same in the new context.

      Reflective binding should work independent of how the readable property is implemented, either via a readable property or via a getter. In code: would expect both testCases below to pass.

      Depending on perspective, the error happens either in TableColumn.getCellDataReflectively or in the underlying PropertyReference: either the former or the latter should try to get a readable value by both ways before giving up as not-readable.


          public static class BeanWithProperty {
              StringProperty name = new StringProperty();
              
              public BeanWithProperty(String name) {
                  this.name.set(name);
              }
              
              public StringProperty nameProperty() {
                  return name;
              }
          }
          
          @Test
          public void testTableColumnReadableProperty() {
              ObservableList<BeanWithProperty> beans = FXCollections.observableArrayList(
                      new BeanWithProperty("myname"));
              TableView<BeanWithProperty> table = new TableView<BeanWithProperty>(beans);
              TableColumn<BeanWithProperty> column = new TableColumn<BeanWithProperty>("column");
              column.setProperty("name");
              table.getColumns().setAll(column);
              assertEquals(beans.get(0).nameProperty().get(), column.getCellData(table, 0));
          }
          
          public static class BeanWithGetter {
              StringProperty name = new StringProperty();
              
              public BeanWithGetter(String name) {
                  this.name.set(name);
              }
              
              public String getName() {
                  return name.get();
              }
          }
          
          @Test
          public void testTableColumnGetter() {
              ObservableList<BeanWithGetter> beans = FXCollections.observableArrayList(
                      new BeanWithGetter("myname"));
              TableView<BeanWithGetter> table = new TableView<BeanWithGetter>(beans);
              TableColumn<BeanWithGetter> column = new TableColumn<BeanWithGetter>("column");
              column.setProperty("name");
              table.getColumns().setAll(column);
              assertEquals(beans.get(0).getName(), column.getCellData(table, 0));
          }
          
          

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              fastegal Jeanette Winzenburg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: