I have two almost similar custom classes for storing simple String data - they are called \"Patient\" and \"Trace\".They differ from eachother only by the number of defined fiel
The problem is that the values you are passing to the PropertyValueFactory
do not match the names of the properties, which are defined by the get...()
and set...(...)
methods.
Since you are using reflection to look up the names of the fields (not the properties) you have defined, for the Trace
class the values passed to PropertyValueFactory
are "action", "status", "message", and "time". So the table view will attempt to populate the values for the columns by calling getAction()
, getStatus()
, getMessage()
, and getTime()
on the Trace
objects in each row. Since there are no such methods, you don't get any values displayed.
To fix this, you can do one of the following:
getVariablesNames()
method to return the names of the properties (i.e. return new String[] {"actionText", "statusText", "messageText", "timeText"};
). Since you repeat the method in each class rather than reusing it, you don't make things more verbose, and this would potentially perform better (though you are unlikely to observe any differences in practice).actionText
, etc.). This of course imposes convention requirements on your class definition.