java - Does commitedit() change the properties of it's object? -


i wondering if commitedit() method of tablecell in javafx updates property of object row represents.

from tableview documentation:

by default tablecolumn edit commit handler non-null, default handler attempts overwrite property value item in currently-being-edited row. able cell.commitedit(object) method passed in new value, , passed along edit commit handler via celleditevent fired. matter of calling tablecolumn.celleditevent.getnewvalue() retrieve value.

it important note if call tablecolumn.setoneditcommit(javafx.event.eventhandler) own eventhandler, removing default handler. unless handle writeback property (or relevant data source), nothing happen. can work around using tablecolumnbase.addeventhandler(javafx.event.eventtype, javafx.event.eventhandler) method add tablecolumn.edit_commit_event eventtype desired eventhandler second argument. using method, not replace default implementation, notified when edit commit has occurred.

so default, calling commitedit(...) cause tablecolumn attempt update value represented cell. if set event handler calling tablecolumn.setoneditcommit(...), remove default behavior.

note default mechanism works casting object returned column's cellvaluefactory writablevalue, , calling setvalue() method. (essentially) work if backing model table uses javafx properties pattern. in other words, should have equivalent to

column.setcellvaluefactory(celldata -> celldata.getvalue().xxxproperty()); 

where xxxproperty() method in model table returns implementation of writablevalue (e.g. property object).


Comments