GWT subclass serialization

I have an RPC service that returns an object of type GameEvent that extends from the event (annotation). When I get the object on the client side, all the properties inherited from Event (eventId, copyEventId, gameTimeGMT) are set to null , while on the server side these properties have values.

 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() { } } 

Update: I am using the gwt-platform (MVP implementation). Here is the challenge to the client side of the service. result.getGE() returns a GameEvent object, but has null properties.

 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()); } }); 

Action handler:

 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); } } 

Result:

 public class GetFormattedEventResult implements Result { private GameEvent e; @SuppressWarnings("unused") private GetFormattedEventResult() { } public GetFormattedEventResult(GameEvent gameEvent) { e = gameEvent; } public GameEvent getGE() { return e; } } 
+6
java gwt gwt-rpc gwt-platform
source share
1 answer

I will try to take a hit.

Make sure that the Event class is in the GWT serialization whitelist (the .gwt.rpc file that is created for each service interface). If this is not the case, you may need a GWT trick to add it.

0
source share

All Articles