0

I have a GWT application where MVP pattern is followed.

We have multiple views to show data on UI.

We set the data to view via Activity. Something like this

 public class SomeActivityImpl extends AbstractActivity implements SomeView.Presenter {

       public SomeActivityImpl{
            //some initialization goes here.
       }       

 public void start(AcceptsOneWidget containerWidget, EventBus eventBus) {
          //presenter is set here
          loadDetails();
 }

 private void loadDetails(){
        SomeRequestFactory.context().findSomeEntity().fire(new Receiver<SomeProxy>() {

        @Override
        public void onSuccess(SomeProxy proxyObject) {

          someView.setName("name");
          someview.setSurname("surname");
          someview.setMothersName("mothers name");
        }

 )
 }

Now my question is how can I make sure that all the setters of View are set and nothing is missed?

Is there any solution which is GWT specific or can someone suggest a design pattern?

enrybo
  • 1,787
  • 1
  • 12
  • 20
Sam
  • 2,352
  • 4
  • 32
  • 45
  • Are you saying that your views contain more setters than your view interface and you would like all setters to be set regardless of if they're in the view interface or not? – enrybo Feb 12 '13 at 14:39
  • Or are you saying that you want to ensure that none of the setters in the view interface are missed? – enrybo Feb 12 '13 at 14:47
  • @enrybo I want to say that none of the setters are missed. – Sam Feb 12 '13 at 15:17
  • Well your activity should know what's to be set. It's up to him to ensure that it's done. He has access to the view interface so it shouldn't be a problem. Something you might do though is setting up some logic in the view implementation which will call the presenter asking for specific values to set. – enrybo Feb 12 '13 at 16:03
  • 2
    if you want to make your view track fields consistency I would recommend to introduce a single method like setFieldsAfterLoad(...) where you can encapsulate the validation logic etc. But usually it's a presenters task to keep the logic. – Alexey A. Feb 12 '13 at 16:03
  • Like @Alexey said, it's up to the presenter ensure he sets everything that is needed. – enrybo Feb 12 '13 at 18:03
  • @Alexey If possible do you have a sample code or some reference which would show me some implementation of what you have suggested? – Sam Feb 13 '13 at 01:25

1 Answers1

0

You should use the editor framework. It has a Request Factory driver to help you use it with request Factory. Here's a good tutorial

If you don't like that tutorial, consider looking at GWT in action

jgleoj23
  • 262
  • 2
  • 9