Search code examples
gwtrequestfactory

get Objects with with() clause RequestFactory GWT


Hello I just set up RequestFactory for my GWT Project. It works nicely but I can't get the Object Fields of an Object I have a BuslineProxy and a Bus Proxy

buslineContext.findAll().with("buses").fire(new Receiver<List<BuslineProxy>>() {

    @Override
    public void onSuccess(List<BuslineProxy> response) {

        String requestedData="";
        for (BuslineProxy busline : response)
        {
            requestedData+="Busline " +busline.getName() +" with id " + busline.getId()+"\n";
            for(BusProxy bus : busline.getBuses())
            {
                requestedData+=bus.getId()+"\n";
            }
        }
        Window.alert(requestedData);
    }
});

My Server Object Busline has a List field called buses. I figured that I just simply need to put the field I want to access in the with clause. It doesn't work though and I only get all the buslines but their list of buses is empty. Thanks for any help.


Solution

  • Florent was correct that the data was empty due to a minor mistake. The bigger problem though was that the entity proxy bus did not have a default constructor and a static findAll method, even though it is never instanciated directly. The constructor is empty and the findAll method returns null, but RequestFactory still needs them!