質問

イベントから拡張される型GameEventのオブジェクトを返すRPCサービスを持っています(要約)。クライアント側にオブジェクトを取得すると、イベントから継承されたすべてのプロパティ(eventid、copyeventid、gametimegmt)がに設定されています null 一方、サーバー側では、これらのプロパティには値があります。

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-Platformフレームワーク(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シリアル化ホワイトリストにあることを確認します( .gwt.rpc 各サービスインターフェイスに対して生成されるファイル)。そうでない場合は、そうする必要があるかもしれません トリックGWT それを追加します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top