ListModel question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ListModel question

Bruno Brasesco
Hi all,

I have Banks and each Bank has anOrderedCollection with Accounts.

BankPresenter has a ListView (ListPresenter) to show his Accounts.
Like this:
BankPresenter methods.
model: aBank

    super model: aBank.
    accountsPresenter model: (ListModel on: aBank accounts).

But when I add anAccount to the Bank in the Presenter, the ListPresenter do
not update contents.
Do I miss somethig ?
Or I should tell to the ListPresenter to update contents ?
There's any way to have an automatic update ?

Best Regards
Bruno Brasesco


Reply | Threaded
Open this post in threaded view
|

Re: ListModel question

Christopher J. Demers
Bruno Brasesco <[hidden email]> wrote in message
news:9le1o4$906mc$[hidden email]...
...
>     accountsPresenter model: (ListModel on: aBank accounts).
>
> But when I add anAccount to the Bank in the Presenter, the ListPresenter
do
> not update contents.
> Do I miss somethig ?
> Or I should tell to the ListPresenter to update contents ?
> There's any way to have an automatic update ?
...

The problem is that you are probably adding the account to the collection in
the ListModel rather than to the ListModel itself.  If you add the account
to (accountsPresenter model) you will see the list refreshed.  If you add
the account to (aBank accounts) you will not see it reflected in the list
box unless you tell it to refresh.  One way to get around this, and what the
OA personal money application uses, is to initialize the accounts instance
variable as a ListModel (see PersonalMoney<<initialize).  That way when you
add the account directly to the instance variable it will be refreshed in
the list box.  This seemed a little strange to me at first as you are bring
some UI issues into the model, but the ListModel is supposed to be a almost
transparent wrapper for collections so it does not usually get in the way of
model logic.

Hope that helps,

Chris