Using codehaus 'ObjectMappper' class in GWT application to parse json - gwt

I want to use ObjectMapper class from 'codehaus' library in client side of GWT application. I am getting error no source code available for ObjectMapper class .
Any solution for this? Is it not possible to use Java library classes in GWT application?

It is possible to use Java source code in GWT, but libraries should be adapted. Some libraries just require a GWT module to indicate that the source code should be transpiled by GWT and others might require some level of adaptation. Concretely, anything related to reflection is not supported in GWT, and Jackson uses a lot of reflection so it is quite difficult to adapt.
Solution: You should use an alternative implementation like https://github.com/nmorel/gwt-jackson or https://github.com/DominoKit/gwt-jackson-apt. Or just delegate the coding/decoding of JSON to the native JSON optionally applying the JsInterop DTO strategy to make the models work in both GWT client side and JRE server side.

Related

Why GWT is not supporting all java classes or methods?

From the below link I understood that GWT supporting only a subset of classes or methods in the following package in client side.
java.lang
java.lang.annotation
java.util
java.io
java.sql
https://developers.google.com/web-toolkit/doc/1.6/RefJreEmulation#Package_java_lang
Why is it so?
I think it make more problem in development because I am using only GWT client and using REST Web service instead of server.
Is there any new release of jar like gwtx (new release for supporting persistence,annotation etc) for using all classes and methods in the above packages.
and my main doubt is why they are not supporting all?
To support translating Java to JavaScript, every standard class has to be emulated, i.e. recreated in such a way that the GWT compiler knows how to translate it to JavaScript. An ArrayList for instance is based around a JavaScript Array, String methods have to be emulated on top of a JavaScript String, etc.
And there are things that are simply impossible to emulate (files, sockets). A few other things are not emulated on-purpose, because the emulated version, while technically possible, would be much less performant than a more direct mapping of the browser APIs, and GWT strives for performance (third-party libraries, such as GWTx, can provide such emulations if needed) more than compatibility (the choice of Java as the language was primarily to leverage tooling, not provide a compatibility layer to allow reuse of existing libraries).
Finally, reflection is not supported as it would make it impossible for the compiler to prune dead code and do all its optimizations: how would it know that a particular class, field or method is not actually used by reflection rather than direct calls?

disable gwt obfuscation for certain model classes

Is it possible in GWT 2.4+ to disable obfuscation for certain java model classes?
The reason I am asking this question is we use GWT RPC to talk to the server and need to store these objects returned etc in local storage using the Indexed DB API, we are currently using websql api. If GWT obfuscates/renames your properties etc then this renders using the Indexed DB API useless in your code.
Maybe there is a way to ask GWT to replace a property string with the obfuscated version in your Indexed DB api queries?
I could create a whole new java model that uses javascript overlays so these are preserved when GWT compiled and replace GWT RPC with JSON RPC but this would be a lot of work.
Any other ideas would be appreciated!
I also looked at the AutoBean framework which produces nice JSON output of your model interfaces but I don't think has a nice simple javascript representation under the hood.
You can set GWT Compile style attribute to PRETTY or DETAILED. so that GWT will not replace the class, method or variable names. For more information refer this link.

GWT Background Study For Project help!

I am currently doing a project on GWT and in the background study, I need to perform research on GWT. I have included many things which I will list below. Can anyone point out something that I may be missing or what other interesting thing concerning GWT I can include? The following is a list of all the topics that are currently included:
GWT Java to JavaScript Compiler
Deferred Binding
JSNI (JavaScript Native Interface)
JRE Emulation Library
GWT-I18N (Internationalization and Configuration tools)
GWT’s XMLParser
Widgets and Panels
Custom Composite Widget
Event and Listeners
Styling through CSS
GWT History Management
GWT Hibernate Integration (through GLead)
MVP (Model-View-Presenter) for GWT through Model View Presenter Application
Controller and Event Bus
Server Calls using RPC and request builder
Comet
Serialization in GWT
JSON (JavaScript Object Notation)
Testing Web Application with GWT
JUnit Benchmarking Selenium
Further work in GWT such as Ext-GWT and smart GWT
Here my additions may be helpful to you
GWT Logging
Editors
Speed Tracer
RequestFactory
GWT animation
Formatter (NumberFormat, DateFormat)
one of the most important things
GWT <-> GAE(Google App Engine)
and last (you forgot)
GWT modules :)
I am not sure if it is implicitly included in one of the points you listed but :
Client Bundle
The resources in a deployed GWT
application can be roughly categorized
into resources to never cache
(.nocache.js), to cache forever
(.cache.html), and everything else
(myapp.css). The ClientBundle
interface moves entries from the
everything-else category into the
cache-forever category.
You may want to take a look into UiBinder and RequestFactory as well as some of the development and testing tools such as GWT Designer and Speed Tracer.
If you are planning to use Spring , on server side, you should consider gwt-spring integration.
although, gwt designers do not provide reflection and recommend not to use the reflection, using reflection is inevitable, and if you use carefully, its cost is bearable..

Creating a GWTclient with Clojure on the server in Eclipse

I would like to make a website using GWT, so I can use the java-to-javascript compiler for the client side. However, I would like to make a service that my client can call using the default RPC-mechanism of GWT, in Clojure instead of Java.
I don't know anything about Maven. I use Eclipse to generate and develop the GWT project. How do I set this up?
If you want to use GWT-RPC mechanism, you create three java files: two interfaces YourService.java and YourServiceAsync.java, and server-side implementation YourServiceImpl.java
Then you create Clojure code with business-logic, link it as library to the main GWT project.
Your implementation file will receive requests from client and call clojure for implementation.
I'd like to realize such approach too.

What purpose do the collection classes defined under com.google.gwt.dev.util.collect.* serve?

I accidentally used HashSet and HashMap defined under the package com.google.gwt.dev.util.collect in the client side code. Found out the package does not have a module xml file and hence these collection classes are not meant to be used on the client side.
What is the purpose of having these classes in the GWT SDK, if these aren't supposed to be used within the client package? There definitely has to be some benefit from these classes to merit inclusion in the SDK.
What am I missing?
Those collection implementations were written by Google engineers to improve the performance (specifically memory usage) of the GWT internals, such as the Java-to-JavaScript compiler. They are implementation details not intended to be part of the public API and should not be used by GWT developers.