Search code examples
formsgwtmvprequestfactory

Best practice, reuse the RequestFactory calls in different forms


I'have several forms that use the same Listboxes. The ListBoxes are populated from a RequestFactory call, this code, for example, is called from each presenter in order to populate a ListBox.

EntityBaseRequestContext context =  entityContextProvider.get();
    context.getDomaineValeursByName("DomaineActivite").fire(new Receiver<List<DomaineValeursProxy>>() {
        @Override
        public void onSuccess(List<DomaineValeursProxy> domaineValeursProxyList) {                              
            display.setDomaineActivitieList(domaineValeursProxyList);   

        }
    });

What's the best way to avoid redundancy of this code in each presenter ? Thank you

I'am using Uibinder,GIN,MVP,GWT2.4


Solution

  • Proxies returned back in the Receiver callback are not attached to any context, you may safely keep them in a accessible location and use it in all of your listboxes, just like the way you would work with simple beans. Fire this request just once at the start of your application and use it through out, forget that context after the call.