Показаны сообщения с ярлыком GWT. Показать все сообщения
Показаны сообщения с ярлыком GWT. Показать все сообщения

понедельник, 10 августа 2015 г.

GWT 2.7.0. Deserialize json on server with Autobean framework

One can use JSON libraries to deserialize json to POJO. How to do it with GWT?

GWT ships with Autobean framework. It allows you to serialize the json on client. But, we can use it on the server side too.

Here is the magic:
1) define the the interface which extends the AutoBeanFactory
2) on the server side use beanFactory = AutoBeanFactorySource.create(Your_Factory_class.class);

AutoBeanFactorySource is in com.google.web.bindery.autobean.vm.AutoBeanFactorySource package. One clue is that it is experimental. So check how it is working in your environment.

3) To decode json to POJO use:
AutoBean<Your_POJOInterface> bean = AutoBeanCodex.decode(
                    beanFactory, Your_POJOInterface.class, jsonString);
Your_POJOInterface requestObject = bean.as();

4) That is all! Just plain GWT and no other special mappers!

четверг, 6 августа 2015 г.

Check GWT and SmartGWT versions in project

You have a GWT & SmartGWT project.  How to check the version of this jar libs in project?

For the GWT version open the *.cache.* file and see the *$gwt_version* variable.

As for SmartGWT see the class com.smartgwt.client.Version class.