Dynamically creating GWT screens using Metadata? - gwt

I have an AWT applet application that needs to be ported over to GWT. The applet screens are described in meta data and the applet renders each screen dynamically using reflection.
We'd like the same thing in GWT/ExtGWT.
I've built a working version of this ExtJS whereby the metadata is turned into ExtJS Screen configs in the form of JSON. The drawback with this approach is the "wiring" of controls to data needs to be written in Javascript.
GWT is preferred since it'd be all Java code, no JS. Upon digging in it's possible to render the screens using GWT off the metadata using GWT.create().
The problem I'm having is the wiring to hook a dynamically created button for example to an event handler requires reflection which is not supported in GWT.
Is this conclusion correct? and if so, are there any other ways to achieve this type of dynamic UI using ExtGWT?

For extGWT where we don't have declarative UI's the easiest solution might be to just add a mapping/config your handlers in java which refer to instantiated classes. of the handlers, i.e.:
Map<String, ActionListener> mapping = new HashMap<String, ActionListener>();
mapping.put("HandleClicked", new HandleClickedActionListener());
then you can try to find an implementing class for your meta data.
For pure GWT 2 you can take a look at http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiBinder.html#Simple_binding on how it's done there. it might be possible to create a similiar solution which annotated methods for you own extgwt solution like the one in gwt.

Related

Orbeon FormBuilder Embedding

How do i embed Orbeon form builder in a non java webapp, (Plain Javascript) as well as customising its look (CSS). I am currently embedding it using an iframe but it doesn't seem to be a very good option. Any suggestions are appreciated.
Embedding Form Builder with the JavaScript embedding API isn't supported yet. At this point, you can only embed Form Builder with the Java embedding API.
There is no fondamental reason why this couldn't possible from the JavaScript API; it is just a question of issues that still need to be ironed out (for more on this, see issue #4483). So, as I write this, if you can't use the Java embedding API, you're correct and the only way to do this is to use an iframe.

GWT's handler registration in second window

I develop a multi window application with GWT by using a popup. Since Window.open() does not return a reference to the created window, i wrote my own JSNI stuff to obtain the new window's document so i can populate it. It works well, but the whole GWT event handling does not work on the widgets in the new window. At present my solution is to use JSNI for event handling. But it would be simpler if the widgets supported their GWT handlers. Any ideas?
Have you considered using a popup instead of a complete new window?
I don't believe communication between different windows is directly supported in GWT.
You probably have to build or use a library to communicate via localstorage for example.

How to achieve Two Way data binding in native GWT?

We have been using GWT for around 4 years now. One of the most often discussed features missing in native GWT is data binding. Reading across AngularJs another Google offering, i came across http://devgirl.org/2013/03/21/fun-with-angularjs/ . I do not wish to use GXT or any other third party tools. I also wish to avoid generator related solution.
Is there any way this will ever be implementable in pure native GWT?
Is there any specific reason why GWT cannot provide this out of the BOX?
Have you tried GWT Pectin?
I have used it successfully in a larger project some time ago.
I suggest you try HexaBinding, which is non invasive and only focused on data binding. Here is the link : https://github.com/ltearno/hexa.tools/blob/master/hexa.binding/README.md
It works with pure Java, GWT and will soon work also with Android and JavaFX. It may even work with J2Objc but not sure yet...
I read the post you mention on devgirl about AngularJS. In that post the "2 way data binding" refers to the property of the code to reflect automatically on the view the changes that occurs to the data that the view is currently displaying.
This is achieved in GWT since version 2.1 with the Cell Widgets
In the first paragraph of the Cell Widgets documentation I linked above it is clearly stated that:
A cell widget can accept data from any type of data source. The data
model handles asynchronous updates as well as push updates. When you
change the data, the view is automatically updated.
If you want to do in GWT something as basic as the example in the devGirl post you need to write a onKeyup handler (in AngularJS you should write a Scope to this purpose) that would copy what you entered to the linked label. Something like this:
...
final TextBox nameField = new TextBox();
final Label enteredName = new Label("");
...
public void onKeyUp(KeyUpEvent event) {
enteredName.setText(nameField.getText());
}
...

GWT - Graphical representation of a tree

I want to represent a Tree in my GWt Project in a another way as the standard graphical
representation.
Drag & Drop should be able.
Like this one:
http://s1.directupload.net/file/d/2603/yzo588bb_jpg.htm
Do you know a good GWT Extension to realize this?
I have already looked at the Google Web Toolkit Gallery.
Do you think something like this would solve the problem?
http://gwtgallery.appspot.com/about_app?app_id=86
I'm using Raphaël Gwt for such graphic stuff.
I've tried Vectomatic once, but it is no fun to write, because it seems like the author had no Idea what a namespace is (Several classes starting with OMSVG) and it doesn't "feel" like writing a java programm.
On the other side, with Raphël-GWT is a binding to a javascript-library, thus you have (llittle) Preformance tradeoff for loading an external Cross-browser javascript library.

SmartGWT UI definition using XML

I have been using UIBinder on SmartGWT widgets rather successfully.
However, I have to extend each SmartGWT widget that I use to comply with UIBinder's requirement. Occasionally, I have to masquerade a SmartGWT widget into com.google.gwt namespace, or masquerade a non-GWT-widget as a GWT widget. I extend widgets on as-needed basis.
So, I am starting to wonder, may be SmartGWT already has a UI XML format and I might be doing all this UIBinder acclimatization just to reinvent SmartGWT's wheel.
I have read and reread source codes of the showcase and delved into some of the SmartGWT source code, as well as reading the javadocs.
All I found is XML or Json for communication between server and client.
Is there any UI def XML available for SmartGWT whether gwt-compiled to client-side javascript or like Vaadin's server-side generated UIDL?
And if you happen to be an Isomorphic agent, could you tell us if there are any plans to let SmartGWT play with UIBinder (to preclude me from having to massage SmartGWT widgets on my own anymore)?
Yes, there is a SmartGWT XML component definition - the one used by Visual Builder and Reify, and which you can also write directly. See these docs and this FAQ item:
http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/ComponentXML.html
http://forums.smartclient.com/showthread.php?t=8159#loadVBScreen
As the FAQ clarifies, we recommend using this XML format for a set of use cases that heavily overlaps with what UIBinder is for, that is, keeping your layout and basic component definitions in a declarative format that designers can edit and which can be edited by visual tools, and having your actual Java event handling and other programmatic code separate.
However we strongly recommend against having that declarative format be HTML (as UIBinder does it) because that introduces lots and lots of cross-browser layout issues.
We are likely to eventually support UIBinder as well for the few use cases where it is not redundant with our own XML format. If you need that to happen sooner, consider Feature Sponsorship:
http://www.smartclient.com/services/index.jsp#features
For XML smartclient has the componentxml which is XML based ui design and use JavaScript to have client side logics. You need not compile your app every time in development environment and just reloading of the browser will have the change included and you can test it.