SmartGWT Datasource customization tutorial - gwt

I'm looking for a good tutorial on how to customize a DataSource in SmartGWT (a code sample will also do for now).
Some details:
I have a GWT project which uses a proprietary client-server protocol for fetching data (with an extensive API based on GWT classes). The server is non-GWT based, i.e. GWT is used only for client side.
I'd like to use SmartGWT's widgets with this data by creating a custom DataSource which will interact with the existing GWT infrastructure.
Does anybody know of such a resource?
EDIT:
Charles Kendrick's answer worked for me.
For a working code example, you can see this.

You do this via overrides of transformRequest and transformResponse - see the documentation of these methods for an overview:
http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/data/DataSource.html#transformRequest(com.smartgwt.client.data.DSRequest)
http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/data/DataSource.html#transformResponse(com.smartgwt.client.data.DSResponse,%20com.smartgwt.client.data.DSRequest,%20java.lang.Object)

Related

How to create an API REST?

I want to reach the data saved in a mysql server for an Android phone. I thought about to connect directly the phone to the mysql but it is a bad practice because someone can get the user/pass of the DB.
However the REST architecture maybe it's a solution for my problem. I found the toolkit GWT but I don't know if it's the best way to solve my problem and what I need to use the GWT.
And I got 2 questions basically:
The GWT is good for my purpose?
Need a Tomcat server for example to set the GWT code?
One annotation, the data is for an app Android, there is no HTML interface .
Nowadays I'm working at localhost. Thanks for the answers.
As far as I understand, you want to implement a RESTful service (Web API). GWT targets the Web UI to be able to build it using Java and compile it into JavaScript. I think that it's not what you expect.
Here is a link that provides you hints about concepts of REST: https://templth.wordpress.com/2014/12/15/designing-a-web-api/. It will describe you what is a RESTful service and how to design it.
There are several technologies to build RESTful services (server-side frameworks). I can list two of them:
Restlet (see this link http://restlet.com/technical-resources/restlet-framework/tutorials/2.3 and http://restlet.com/products/restlet-framework/)
JAX-RS and its implementations (Restlet, Jersey, EasyRest). See this link for example: https://templth.wordpress.com/2015/03/06/getting-started-with-resteasy/.
Hope it helps you,
Thierry

GWT - Create something like MobileWebApp using GWTP

I am trying to create an application which will have different views for mobile, desktop and tablet. It is on the lines of MobileWebApp sample from GWT. I am looking at GWT MVP tutorial and have a basic app working.
I was thinking if I should use GWTP and if there would be any advantages of using GWTP instead of GWT MVP(activities and places)
Also, any ideas how different views would bind to the same presenter. There might be differences in what features are available on mobile view and desktop view.
I have done something like this, although at a time before Activities and Places. So back then I've written the MVP framework myself. I placed all the common code, such as Presenters, TransferObjects and Utilities in a separate GWT module. Then each UI became a separate project as well, holding it's View classes and UiBinder stuff, inheriting from the common module. So actually each UI project is a complete GWT application. The GWT applications have to be deployed under different context, thus have different URLs. You then need some smart JavaScript on your welcome page to redirect a visitor depending on there device.
I don't think you can solve this in one GWT app. Or you'd have to come up with a really really clever solution using Deferred Binding (probably it's replacement functionality) and the Linker subsystem.
You can create different views in for a presenter in gwtp. GWTP makes it easier to handle such a scenario. There is an open-source Customer Experience framework which has a sample to create a mobilewebapp using GWTP. You can check it out here- http://code.google.com/p/gwt-cx/

GWT CRUD GUI Model

Good day. I'm still learning GWT so please help me. I'm working on a project - Web Application with GWT on the Client Side. This app has lots of CRUD operations so I'd like to make a model for this. Can anyone suggest a prototype for my CRUD class?
CRUD on this app goes something like this:
When I clicked the Details button in a module, a popup will be shown that allows the user to do CRUD operations. This popup do have the module title, info on the selected item, and the buttons - Edit, New, Delete.
I have already finished building the base GUI for this project but I'm just starting to work on each module. I choose to begin on those module with CRUD operations. So, please help me and give your ideas on this project. Thanks in advance :)
Your question is a little bit general.
You probably have to deal with two questions which can be handled separately:
Communication with the backend.
GUI for CRUD operations
Communication with the backend:
It depends on which kind of backend you are using.
Java-backend:
For Java backends the recommended client-server communication protocol is RequestFactory.
Non-Java-backend: In case you are using a non-java backend (python, PHP, etc) you have to use RequestBuilder using JSON or XML (I would recommend JSON).
For mapping JSON/XML to DTO's and vice verca you can use different methods:
Third party tools like piriti which are based on GWT generators
Javascript Overlay Types (JSO)
GWT Autobean framework (which is used by RequestFactory btw).
GUI for CRUD operations
For mapping your DTOs to your UI and doing the CRUD operations you can do it either:
manually
with the Editor framework
I would recommend to use the Editor framework as it reduces the amount of boilerplate code
to move an object from your object graph to the UI and back.
The Editor framework works well with RequestFactory (RequestFactoryEditorDriver), Autobean (SimpleBeanEditorDriver) and Javascript Overlay Types.

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..

GWT Dynamic Module Loading

Is there a mechanism to dynamically load a GWT Module?
The idea is to create a pluggable GWT-based system: a core GWT module that dynamically loads another GWT module and a bus communication system to permit the communication through loaded modules.
Any help?
Possible duplicate of Web Application using OSGi and GWT
Also, see the information in this GWT User forum thread - http://groups.google.com/group/google-web-toolkit/msg/4a3f912cb89a7256
To summarize, its possible, but not recommended. Your requirement is orthogonal to GWT's philosophy and architecture. If you must, the GWT Exporter project is a useful starting point to enable communication between modules.
Code splitting does successfully handle the separated-loading issue -- but it does not address the separated-compilation issue.
Modular-interoperability with separated-compilation will never be the recommended default but GWT team should look into this in future.
If we are talking about a plug-in based architecture, different plug-in developer should develop their own UI and compile and give to the framework. Framework should dynamically load them.
I am still looking for and way to do it (do it better way).
You can use code splitting to dynamically loading the code when ever you want.
Have a look
http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html
See also comments at http://code.google.com/p/google-web-toolkit/wiki/CodeSplitting, starting at 6th comment.