--- On Thu, 7/17/08, Ted Husted <[EMAIL PROTECTED]> wrote:
> As mentioned, to refresh the model, we remove the existing
> model and push the latest version. For a "refresh" operation,
> we might expect the new instance to replace the old instance 
> in the same stack position.
> 
> In RefreshModelBeforeResult, we already have a reference to
> the old model ("Item"). Could we just replace one object
> with another?
> 
>             for (Object item : root) {
>                 if (item == newModel) {
>                     needsRefresh = false;
>                 }
> +             else {
> +               item = newModel
> +             }

Would that replace every non-newModel item? Maybe something closer to this, 
using your code as a start, then ruining it with returns (it's late, I'm groggy 
:)

    boolean replaced = false;
    for (Object item : root) {
        if (item == newModel) {
            return;
        } else if (item == originalModel) {
            if (newModel != null) {
                item = newModel;
            } else {
                root.remove(item);
            }
            return;
        }
    }

    if (newModel != null) {
        stack.push(newModel);
    }

The other issue I mentioned is that if newModel is null the current code 
doesn't push it--there's always a chance of the stack *depth* being modified, 
even if the stack index of the model isn't. This seems unavoidable and may not 
be an important issue.

Hmm, if for some reason there were two instances of the model (maybe even 
original *or* new models?) on the stack there could be some confusion.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to