GWT serialización de una subclase
-
01-10-2019 - |
Pregunta
Tengo servicio RPC que devuelve un objeto del tipo que GameEvent
se extiende desde eventos (resumen). Cuando llego el objeto en el cliente
secundarios, todas las propiedades heredadas de eventos (eventId, copyEventId,
gameTimeGMT) están ajustados en null
mientras que en el lado del servidor, estos
propiedades tienen valores.
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() {
}
}
Actualización: Yo uso el marco GWT-plataforma (aplicación MVP). Esta es la llamada a la parte del cliente del servicio. El result.getGE()
devuelve el objeto GameEvent pero con propiedades 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());
}
});
El controlador de acción:
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);
}
}
El resultado:
public class GetFormattedEventResult implements Result {
private GameEvent e;
@SuppressWarnings("unused")
private GetFormattedEventResult() {
}
public GetFormattedEventResult(GameEvent gameEvent) {
e = gameEvent;
}
public GameEvent getGE() {
return e;
}
}
Solución
Voy a tratar de tomar una puñalada.
Verificar que la clase Event se encuentra en la serialización GWT lista blanca (el archivo .gwt.rpc
que se genera para cada interfaz de servicio). Si no es así, puede que tenga que GWT en la adición de la misma.