PDA

View Full Version : [CLOSED] ModelReader does not honor configdata



Grandiosa
10 Jun 2008, 1:44 AM
The ModelReader class:


public class ModelReader<C> implements DataReader<C, ListLoadResult<ModelData>> {

public ListLoadResult read(C loadConfig, Object data) {
if (data instanceof ModelData) {
List list = new ArrayList();
list.add(data);
return new BaseListLoadResult(list);
} else if (data instanceof List) {
return new BaseListLoadResult((List) data);
} else if (data instanceof ListLoadResult) {
return (ListLoadResult)data;
} else {
throw new RuntimeException("Error converting data");
}
}
The loadConfig object is unused. If the incoming data is a list, shouldn't the ModelReader only return a subset of the list? I mean if the loadConfig parameter is a BasePagingLoadConfig object ?

This is needed in a custom proxy's load method using this code:

PagingLoadResult<Data> result ;
result = reader.read(config, data);

where data is of type Data, and can be set by the user at any time.
The reader object would be a ModelReader if the BasePagingLoader was constructed with this reader as an argument.

darrellmeyer
10 Jun 2008, 1:19 PM
It is not the job of the reader to limit or filter the data it is passed. It is the job of the loader to return the correct data.

Grandiosa
11 Jun 2008, 2:21 AM
Fair enough. But the fact that the config object is there led me to think I should use it like this :-)

Looking at the other DataReader implementations none of them actually use the config object, so maybe it should be removed from the method signature...

darrellmeyer
11 Jun 2008, 8:39 AM
Although no GXT readers use the load config it is possible that anyone creating their own reader may want to use it.