0
votes

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?

1
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
Or are you saying that you want to ensure that none of the setters in the view interface are missed?enrybo
@enrybo I want to say that none of the setters are missed.Sam
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
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.

1 Answers

0
votes

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