PDA

View Full Version : How do I configure the ListLoader with RequestFactoryProxy in GXT 3 ?



rcbeuker
8 Sep 2011, 1:25 PM
I try to wire up a RequestFactoryProxy to a ListLoader and connect this to a ListStore (gxt3.0_dp2). How do I specify the ListLoader?

I tried something like;


private final ListLoader<BaseListLoadConfig, BaseListLoadResult<ArticleProxy>> mListLoader = new ListLoader<BaseListLoadConfig, BaseListLoadResult<ArticleProxy>>(mRequestFactoryProxy);

with mRequestFactoryProxy


private final RequestFactoryProxy<ArticleProxy, List<ArticleProxy>> mRequestFactoryProxy = new RequestFactoryProxy<ArticleProxy, List<ArticleProxy>>()
{...}


But this is not correct;


[ERROR] cannot find symbol symbol : constructor ListLoader(com.sencha.gxt.ui.client.data.loader.RequestFactoryProxy<com.randb.pizzapalace.shared.proxy.ArticleProxy,java.util.List<com.randb.pizzapalace.shared.proxy.ArticleProxy>>)

How do I configure the ListLoader with mRequestFactoryProxy?

sven
9 Sep 2011, 12:25 AM
Your generics do not match. One time you say it returns a List and one time you say it returns BaseListLoadResult. Basicly this is what your errormessage told you.

You need to add a ListReader here that transforms your list to a listloadresult


final RequestFactoryProxy<BaseListLoadConfig, List<NamedProxy>> mRequestFactoryProxy = new RequestFactoryProxy<BaseListLoadConfig, List<NamedProxy>>() {

@Override
public void load(BaseListLoadConfig loadConfig, Receiver<? super List<NamedProxy>> receiver) {


}


};


final ListLoader<BaseListLoadConfig, ListLoadResult<NamedProxy>> mListLoader = new ListLoader<BaseListLoadConfig, ListLoadResult<NamedProxy>>(
mRequestFactoryProxy, new ListReader<NamedProxy>());

I have not tested this code and this code may change for any future preview release.

rcbeuker
9 Sep 2011, 6:47 AM
Hello Sven,

Thanks for your reply. I know the GXT3 code is still changing, but meanwhile I'll try to understand what's going on /:). Sure I did know the generics did not match, but the question was how to transform the proxy list into the listloadresult...

(Meanwhile I updated to gxt-3.0.0-dp4). Your code compiles, but the whole picture is still not clear to me. Do I have to implement method load? Do I have to use a DataReader for the processing? I mean, somebody has to call my service method (listAll) and put the result into a list...



@Override
public void load(BaseListLoadConfig loadConfig, Receiver<? superList<NamedProxy>> receiver)
{
// what to do here?
}


An example would be great here :D

Regards,

Roland Beuker

sven
9 Sep 2011, 6:52 AM
An example would be great here

I already gave you an example in your other thread. What needs to be done there is done in detailed way in the example i already gave you:

http://www.sencha.com/examples-dev/#ExamplePlace:requestfactorybinding

The only difference is that because using RequestFactoryProxy now you get the Receiver already passed in.

Do I have to use a DataReader for the processing?
You need to use a reader when your proxy returns something different than expected. Like here you return a List but require a ListLoadResult

Do I have to implement method load?
Yes, same as in the example, only that you already have the Receiver

rcbeuker
9 Sep 2011, 10:01 AM
Yes I have both examples :s, but in the old/detailed example (with DataProxy) the call getRootFolder() is called in the method which is now implemented in RequestFactoryProxy...

In the new situation, do I have to place the call in the second load? Can I get an example of this, I'm lost here... :((

Regards,

Roland

sven
10 Sep 2011, 1:16 AM
but in the old/detailed example (with DataProxy) the call getRootFolder() is called in the method which is now implemented in RequestFactoryProxy...


You will call that in the new load method. There you already have the receiver and so do not create a new one. However RequestFactoryProxy is just a helper class. You dont have to use that. You can still use the why how it is done in the examples.

sven
10 Sep 2011, 1:31 AM
In your case it will be something like:



private final ArticleRequestFactory rf = GWT.create(ArticleRequestFactory.class);






final RequestFactoryProxy<BaseListLoadConfig, List<ArticleProxy>> mRequestFactoryProxy = new RequestFactoryProxy<BaseListLoadConfig, List<ArticleProxy>>() {
@Override
public void load(BaseListLoadConfig loadConfig, Receiver<? super List<ArticleProxy>> receiver) {
rf.article().getArticles().fire(receiver);
}
};
final ListLoader<BaseListLoadConfig, ListLoadResult<ArticleProxy>> mListLoader = new ListLoader<BaseListLoadConfig, ListLoadResult<ArticleProxy>>(mRequestFactoryProxy, new ListReader<ArticleProxy>());




It is completly untested code and only written here on the forums. No code checking was done.

rcbeuker
10 Sep 2011, 4:26 AM
Thanks, indeed it is just a helper class... :">