manifoldronin
Nov 13th, 2004, 05:09 PM
I have this account list value model:
public abstract class AccountListValueModel extends AbstractValueModel {
private List accounts_;;
public void refresh() {
accounts_ = getAccountDAO().findAllAccounts();
fireValueChanged();
}
public Object getValue() {
return accounts_;
}
public void setValue(Object value) {
accounts_ = (List)value;
}
public abstract IAccountDAO getAccountDAO();
}
(The abstract method is actually a look-up) An instance of this class is passed to a DynamicListModel which is then used to back a JList. Somewhere else I have:
public static class NewAccountCmdExe implements ActionCommandExecutor {
private AccountListValueModel listModel_;
public NewAccountCmdExe(AccountListValueModel listModel) {
listModel_ = listModel;
}
/***/
public void execute() {
final Account newOne = new Account();
final SwingFormModel model = SwingFormModel.createFormModel(newOne);
FormBackedDialogPage dlgPg = new FormBackedDialogPage(
new AccountForm(model));
TitledPageApplicationDialog dlg = new TitledPageApplicationDialog(
dlgPg) {
protected boolean onFinish() {
model.commit();
listModel_.getAccountDAO().saveAccount(newOne);
listModel_.refresh();
return true;
}
};
dlg.setCloseAction(CloseAction.DISPOSE);
dlg.showDialog();
}
}
I thought that call to refresh() above would trigger a chain of reaction and end up with the actual JList being refreshed, but it actually doesn't, while the new account is indeed saved in the DB. I can even see DynamicListModel logging a line about the value changed event being fired.
Maybe I'm using it in the wrong way?
Thanks.
public abstract class AccountListValueModel extends AbstractValueModel {
private List accounts_;;
public void refresh() {
accounts_ = getAccountDAO().findAllAccounts();
fireValueChanged();
}
public Object getValue() {
return accounts_;
}
public void setValue(Object value) {
accounts_ = (List)value;
}
public abstract IAccountDAO getAccountDAO();
}
(The abstract method is actually a look-up) An instance of this class is passed to a DynamicListModel which is then used to back a JList. Somewhere else I have:
public static class NewAccountCmdExe implements ActionCommandExecutor {
private AccountListValueModel listModel_;
public NewAccountCmdExe(AccountListValueModel listModel) {
listModel_ = listModel;
}
/***/
public void execute() {
final Account newOne = new Account();
final SwingFormModel model = SwingFormModel.createFormModel(newOne);
FormBackedDialogPage dlgPg = new FormBackedDialogPage(
new AccountForm(model));
TitledPageApplicationDialog dlg = new TitledPageApplicationDialog(
dlgPg) {
protected boolean onFinish() {
model.commit();
listModel_.getAccountDAO().saveAccount(newOne);
listModel_.refresh();
return true;
}
};
dlg.setCloseAction(CloseAction.DISPOSE);
dlg.showDialog();
}
}
I thought that call to refresh() above would trigger a chain of reaction and end up with the actual JList being refreshed, but it actually doesn't, while the new account is indeed saved in the DB. I can even see DynamicListModel logging a line about the value changed event being fired.
Maybe I'm using it in the wrong way?
Thanks.