ClientCommUtils and ServerCommUtils, pass object

I’m trying to pass an object with these utility classes but whenever I send a custom object I receive “null” as the object.

private ServerCommUtils client = new ServerCommUtils(new ClientCallback());
#1
Result res = new Result(“test”);
client.call(“printres”, res);

vs
#2
client.call(“printstr”,“test”);

In the receiving function I get the proper string in the second call, but the #1 just gives me null. Do I need to make some modifications to the utils-classes to make custom objects to be sent as well? These classes are a part of the Console addon, but It seems they are used in other components as well.

I solved it for now by instead of passing the customized object, I passed a string with all data and then reproduce the object on the clientside. Would still appreciate an answer if someone knows :slight_smile:

Each class to be passed from the client to the server needs custom serialization support on both sides, and I think only a handful of classes are handled by these utility classes. (I haven’t looked at their source code, but I believe they use the standard Vaadin client-server communication channels or something very similar with the same restrictions.)

Hi,

I must ask where did you find the ClientCommUtils classes? They is part of my add-on libraries. You can see these classes at least as a part of
YouTubePlayer
,
SWFObject
and
Console
add-ons. Currently they are an integral part of the add-ons (to limit the dependencies) and they may behave a bit differently depending on version. If there is enough interest I can package these as separate add-on in the future.

The motivation for these was to make fine-grained component client-server sync easier to implement. These classes implement more RPC-like mechanism on top of the Vaadin’s own paint/changeVariable communication (which is a bit outdated, imho). I think ClientCommUtils are the best suited for integrating existing client-side JavaScript libraries to Vaadin.

Anyway, what Henri said about the serialization is true. There is no generic object serialization currently and only Java primitive types, arrays and Map are supported. A generic DTO pattern could be implemented in the future, but currently it seems to be less needed than it first feel like.

Hopefully Vaadin7 will implement something similar. I truly believe something like this makes components’ client-server sync more robust, efficient and easier to implement.

Definitely package these as an add-on, sounds way too useful. I didn’t even know you had something like this cooked up :slight_smile: