in project have table. when user double clicks on row, editing dialog opens. on opening dialog set values fields, few of choiceboxes. type of choicebox's field custom object, not string.
the code creates choicebox follows:
trade_point.setconverter(new tradepointconverter()); trade_point.setitems(fxcollections.observablearraylist(tradepointsservice.gettradepoints())); tradepoint currenttradepoint = tradepointsservice.gettradepoint(typeofpricebytradepoint.gettradepoint()); trade_point.setvalue(currenttradepoint); where trade_point choice box of tradepoint type. currenttradepoint not null, when @ trade_point's value equals currenttradepoint's value in dialog see no value. items set correctly. in other case same choice box filling correct , here not.
upd: tradepointconverter class:
class tradepointconverter extends stringconverter<tradepoint>{ public tradepoint fromstring(string name){ try { list<tradepoint> tradepoints = tradepointsservice.gettradepoints(); (tradepoint tradepoint1: tradepoints){ if (tradepoint1.getname().equals(name)){ return tradepoint1; } } }catch (sqlexception e){ } return null; } public string tostring(tradepoint tradepoint1){ return tradepoint1.getname(); } } i not sure if converter correct far converting string name totally incorrect. not understand how make correctly visible user (to see name of object) , how store id definite object @ same time. can convert string getting id in case user won't understand object choose.
trade_point choicebox:
private choicebox<tradepoint> trade_point = new choicebox<tradepoint>();
Comments
Post a Comment