GWT's handler registration in second window - gwt

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.

Related

How to use RevealRootLayoutContentEvent for designing of the GWT 2.0 layout system in GWTP?

I have just heard about RevealRootLayoutContentEvent yesterday. I have no idea of how to use it whatsoever in GWTP.
Ok, i am using GWTP on eClipse to crease a presenter like the following picture
We first need to select RevealRootLayoutContentEvent when create the Presenter, eClipse will generate some file, then what to do next?
Can anyone give me an a very simple example of how to use RevealRootLayoutContentEvent in GWTP?
Read
http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#LayoutPanels
If you use RevealRootLayoutContentEvent your application will be put inside RootLayoutPanel. In this case you should avoid using no-"...Layout..." panels.
If you use RevealRootContentEvent RootPanel will be used.

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());
}
...

How to use History.js with GWT?

I want to use History.js from Google Web Toolkit.
I know GWT has History functionality of it's own, but I don't like it because it uses the hashes in the URI, I want to use the new HTML5 History API as much as possible.
The only current way that I can think of to run History.js and GWT together is to write the History.js part in plain Javascript (or jQuery) and then manually call a GWT method.
It would be nice if it was possible to use the whole History.js functionality from within GWT's Java files.
No pain at all with that .
You just simple add your History js file on your document and you can use it .
Here i answered how you can use an external js in GWT .
Using externel js in GWT
After you call the native method you can continue with gwt method

How do I transform a gwt app into a 3rd-party embeddable library

I've built a GWT application that simulates a standalone popup widget. I can invoke a javascript method that pops the widget from the html page that is part of the application (i.e. PopWidget.html) -- the html is basically auto-generated when I create the GWT eclipse project.
Now I'd like to invoke the javascript method from a standalone html (not part of application). When I try to call the javascript method, I am getting a permissions exception. Is this a SOP issue? And if so, How can i either work around this problem or transform the app to behave as an embeddable 3rd-party javascript library?
I've looked in gwt gadgets and this seems like the ticket, but I have not discovered any "popup" gadgets...
You are correct that it is an SOP issue - the default linker used builds an iframe, and loads the app source into that iframe. To prevent the js from running any file on your system, this is locked down (in most browsers).
Take a look at the "Controlling Compiler Output" section of this link http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml- the standard linker (std) uses iframes to protect against possible xss issues, but in your case you want cross origin loading, so you can probably use the xs linker instead.

Dynamically creating GWT screens using Metadata?

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.