Howto use Views which need to get notified by diffrent models with diffrent Data types

0 views
Skip to first unread message

Norman Maurer

unread,
Jun 16, 2009, 2:38:34 PM6/16/09
to gwt-mvc
Hi,

when I have a View which needs to get updated via diffrent models
( which use diffrent Data types), how should I handle the update of
the View ? Get it all done via "model.getValue() instanceof
Whatever" ? From the examples I only see Views which use models which
have the same Data type all over..

Thx for your help

Francois Wauquier

unread,
Jun 17, 2009, 3:44:55 AM6/17/09
to gwt-mvc
Hello

I could see different ways to deal with multiple model listen by a
view.
This solutions are listed in my prefered order, but maybe it wont be
your.

Consider MyView listening 2 models MyModel1 and MyModel2

1/Use instanceof filter on the model
@Override
public void onModelChange(ModelForView model) {
if(model instanceof MyModel1){
...
} else {
...
}
}

2/Use instanceof filter on the model value (as you said)
@Override
public void onModelChange(ModelForView model) {
if(model.getValue() instanceof MyValue1){
...
} else {
...
}
}

3/Refresh all
@Override
public void onModelChange(ModelForView model) {
...refresh value from MyModel1
...refresh value from MyModel2
}

4/Keep References of your differents models
(Dont forget to pass them in the super controller, to active listening
mechanism)

ModelForView model1;
ModelForView model2;
public MyView(MyController controller, MyModel1 model1, MyModel2
model2) {
super("id", controller, model1, model2);
this.model1=model1;
this.model2=model2
}


@Override
public void onModelChange(ModelForView model) {
if(model == model1){
...
} else {
...
}
}

Hope it helps.
François Wauquier

Norman Maurer

unread,
Jun 25, 2009, 6:46:28 AM6/25/09
to gwt-mvc
Hi Francois,

I will try out 1). Thx for the help :)

Bye,
Norman
Reply all
Reply to author
Forward
0 new messages