Francois Wauquier
unread,Jun 17, 2009, 3:44:55 AM6/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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