FXML TableView bind to nested object property
936814Aug 2 2012 — edited Jul 12 2013Hi,
I need to bind a TableColumn of a TableView<MyModel> to a property of an object like that
/****************** Nested Class **********************/
public class MyStatisticsBean {
private final DoubleProperty average = new SimpleDoubleProperty(0);
public double getAverage() {
return average.get();
}
public void setAverage(double value) {
if (value != average.get())
average.set(value);
}
public DoubleProperty averageProperty() {
return average;
}
}
/****************** Model **********************/
public class MyModel {
...
private ObjectProperty<MyStatisticsBean> statistics = new SimpleObjectProperty<MyStatisticsBean>(
this, "statistics");
public final MyStatisticsBean getStatistics() {
return statistics.get();
}
public final void setStatistics(MyStatisticsBean value) {
statistics.set(value);
}
public final ObjectProperty<MyStatisticsBean> statisticsProperty() {
return statistics;
}
...
}
I've tried the following FXML code but it doesn't work:
/****************** FXML TableView **********************/
<TableView fx:id="myTable">
<columns>
...
<TableColumn text="Avg">
<cellValueFactory>
<PropertyValueFactory property="statistics.average" />
</cellValueFactory>
</TableColumn>
...
</columns>
</TableView>
How can I do that?
Thank you in advance.
Andrea
Edited by: atasca on Aug 2, 2012 10:11 AM