6
我有一個RPC服務,它返回一個EventEvent類型的對象, 從Event(抽象)中延伸出來。當我在客戶端 一側獲取該對象時,從事件(eventId,copyEventId, gameTimeGMT)繼承的所有屬性都設置爲null
,而在服務器端,這些 屬性具有值。一個子類的GWT序列化
public class GameEvent extends Event implements IsSerializable {
private String homeTeam;
private String awayTeam;
public GameEvent() {
}
}
// Annotation are from the twig-persist framework which should not
// impact the serialization process.
public abstract class Event implements IsSerializable {
@Key
protected String eventId;
@Index
protected String copyEventId;
protected Date gameTimeGMT;
protected Event() {
}
}
更新:我使用gwt平臺框架(MVP實現)。這是對服務客戶端的調用。 result.getGE()
返回GameEvent對象,但返回null
屬性。
dispatcher.execute(
new GetFormattedEventAction(
id),
new AsyncCallback<GetFormattedEventResult>() {
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
@Override
public void onSuccess(
GetFormattedEventResult result) {
FormattedGameEvent formattedGameEvent = new FormattedGameEvent(
result.getGE());
}
});
操作處理程序:
public class GetFormattedEventActionHandler implements
ActionHandler<GetFormattedEventAction, GetFormattedEventResult> {
@Override
public GetFormattedEventResult execute(GetFormattedEventAction action,
ExecutionContext context) throws ActionException {
GameEvent gameEvent = null;
QueryResultIterator<GameEvent> rs = datastore.find().type(
GameEvent.class).addFilter("copyEventId", FilterOperator.EQUAL,
action.getEventId()).returnResultsNow();
if (rs.hasNext()) {
gameEvent = rs.next();
}
return new GetFormattedEventResult(gameEvent);
}
}
結果:
public class GetFormattedEventResult implements Result {
private GameEvent e;
@SuppressWarnings("unused")
private GetFormattedEventResult() {
}
public GetFormattedEventResult(GameEvent gameEvent) {
e = gameEvent;
}
public GameEvent getGE() {
return e;
}
}
更新了問題。還試圖欺騙GWT,但它不起作用。 – Sydney 2010-08-26 02:34:01
GameEvent具有未實現IsSerializable類型的屬性,這就是爲什麼它不在序列化白名單中。 – Sydney 2010-08-29 14:08:00
啊,這很有道理。對不起,我無法提供更多幫助。儘管如此,GWTC應該發出警告。 – 2010-08-29 15:20:00