PDA

View Full Version : RpcProxy load issues



raj_begood
13 Feb 2009, 9:27 AM
Hi

I have followed the ListViewExample and modified it to suit my needs, I have added an extra param (sessionKey) in the load call as follows, but am receiving some unusual errors.

If I remove the param and only use the callback as a parm, it works fine, but i need to propogate the client session key in each request to the server.

Error


17:25:21,259 INFO [STDOUT] ERROR - (TypeError): b.a.c has no properties
fileName: http://127.0.0.1:8080/secure/gwt-files/com.dummy.ui.modules.desktop.DesktopApp/1145521A73291CAA9935237C83CFDB28.cache.html
lineNumber: 2262
stack: kCc([object Object],[object Object])@http://127.0.0.1:8080/secure/gwt-files/com.dummy.ui.modules.desktop.DesktopApp/1145521A73291CAA9935237C83CFDB28.c
ache.html:2262
l$([object Object],[object Object],[object Object])@http://127.0.0.1:8080/secure/gwt-files/com.dummy.ui.modules.desktop.DesktopApp/1145521A73291CAA9935237C83C
FDB28.cache.html:614




// This is a global var which holds session info.
SessionKey sessionKey
RpcProxy proxy = new RpcProxy() {
@Override
protected void load(Object loadConfig, AsyncCallback callback) {
getServices().loadMetaDatabase(sessionKey, callback); // Fails
getServices().loadMetaDatabase(callback); // Works
}
};
ListLoader loader = new BaseListLoader(proxy, new BeanModelReader());
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
loader.load();


SessionKey


public interface SessionKey extends IsSerializable {
String getKey();
}


SessionKeyImpl


public class SessionKeyImpl implements SessionKey, IsSerializable {

private String key = null;

public SessionKeyImpl() {
}

public SessionKeyImpl(String key) {
this.key = key;
}

public String getKey() {
return this.key;
}


public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

SessionKeyImpl that = (SessionKeyImpl) o;

if (!key.equals(that.key)) return false;

return true;
}

public int hashCode() {
return key.hashCode();
}


public String toString() {
return key;
}
}

raj_begood
16 Feb 2009, 5:12 AM
I guess I should be more clearer, there are no examples showing how to pass in a parameter to a backend service when using RpcProxy apart from PagingLoadConfig. But what if you have a custom parameter to pass in ?

ListViewExample:


RpcProxy proxy = new RpcProxy() {
@Override
protected void load(Object loadConfig, AsyncCallback callback) {
service.getPhotos(callback);
}
};


What if you wanted to pass in say a UserId, so you load photos belonging to that user e.g



String userId = "harry";
RpcProxy proxy = new RpcProxy() {
@Override
protected void load(Object loadConfig, AsyncCallback callback) {
service.getPhotos(userId, callback);
}
};


Any ideas anyone ?

raj_begood
17 Feb 2009, 5:13 AM
Has anyone done something similar ? I'm kind of stuck with this issue.

sven
17 Feb 2009, 5:17 AM
http://code.google.com/intl/de-DE/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=GettingStartedRPC

This is something basic GWT and has not much to do with GXT.

raj_begood
17 Feb 2009, 7:17 AM
Hi Sven

I have found the cause of the issue, its not related as such with the way the call is being made or the api is being used, its to do with a null value being sent as a param.

What happened was that as part of the init/onModule load process I was making a request to the server side to create and store a sesion key which translates to a client context. As this is done async, there was no guarantee when it was being done and the next call was basically depending on this.

Its solved now, sorry about the noise, seems trivial now.