Hi
I am trying to send Class objects from the server to the client, and
then used GWT.create to make instances of these classes. The problem
is that GWT complains that Class objects are not serializable, but the
java.lang.Class does implement the serializable interface.
My service interface looks as follows:
===============
@RemoteServiceRelativePath("timeline")
public interface TimelineService extends RemoteService {
public ArrayList<Class<? extends PeriodTypeInformation>>
getBankPeriods(String id);
}
My Async Interface looks as follows:
===============
public interface TimelineServiceAsync {
public void getBankPeriods(String
id,AsyncCallback<ArrayList<Class<? extends PeriodTypeInformation>>>
callback);
}
My service implementation looks as follows (VacationType is a subclass
of PeriodTypeInformation:
==============
public class TimelineServiceImpl extends RemoteServiceServlet
implements TimelineService {
public ArrayList<Class<? extends PeriodTypeInformation>>
getBankPeriods(String id) {
ArrayList<Class<? extends PeriodTypeInformation>> periods = new
ArrayList<Class<? extends PeriodTypeInformation>>();
periods.add(PeriodTypeInformation.class);
periods.add(VacationType.class);
return periods;
}
}
My calling function looks as follows:
=============
AsyncCallback<ArrayList<Class<? extends PeriodTypeInformation>>>
callback = new AsyncCallback<ArrayList<Class<? extends
PeriodTypeInformation>>>() {
public void onSuccess(ArrayList<Class<? extends
PeriodTypeInformation>> result) {
for (Class<? extends PeriodTypeInformation> period : result) {
timeline.addPeriodToBank(new Period((PeriodTypeInformation)
GWT.create(period)));
}
}
public void onFailure(Throwable caught) {
// Failed - do something
}
};
timelineService.getBankPeriods(timeline.getId(), callback);
PeriodTypeInformation is serializable according to GWT (and so is
VacationType) and both have zero argument public constructors to use
with GWT.create(). If I dont try to send the classes via RPC, but hard
code the two classes instead, everything functions as expected.
Is there something I'm missing or is Class objects not serializable in
GWT?
Thanks
/Morten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---