I am using the current snapshot of the org.apache.cayenne.dataview classes
in a swing application with Cayenne 3.x.
I am having a problem that when I add (programmatically) an item to a combo
box I can only select it programmatically. The object appears to be in the
combo box's drop down list, but it cannot be selected by the user. When
the user selects the object nothing appears selected and
getSelectedDataObject() returns null.
I do not know if this is a bug or if I am missing something or doing
something wrong.
Here is relevant the code where I am populating the combo box:
DataObjectList playerList = new
DataObjectList(ContextManager.getInstance().getDataContext(performQuery(q));
DOComboBox Model newTournamentResultPlayerModel = new DOComboBoxModel();
cmbNewTournamentResultPlayer.setModel(newTournamentResultPlayerModel);
newTournamentResultPlayerModel.setDataObjects(playerList);
newTournamentResultPlayerModel.setViewField(dataView.getObjEntityView("Players").getFieldForObjAttribute("name"));
Here is the code where I add a new item:
Player newPlayer =
(Player)ContextManager.getInstance().getDataContext().newObject(Player.class);
DOComboBoxModel dm =
(DOComboBoxModel)cmbNewTournamentResultPlayer.getModel();
dm.getDataObjects().add(newPlayer);
ContextManager.getInstance().getDataContext(getClass()).commitChanges();
(if here I call dm.getDataObjects.setSelectedDataObject(newPlayer)..it
works)
Any suggestions on what is wrong would be appreciated.
Thanks,
Mark
This archive was generated by hypermail 2.0.0 : Fri Jul 23 2010 - 22:23:24 UTC