This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a question regarding using JSNI to expose one of my GWT methods.
I have am trying to expose a method in one of my GWT classes that fires a message to other UI components.
In my application entry point I expose it with
class_a updates one of its fields, and then calls a static method from class_b.
class_b calls many other classes and static methods to process the msg
Basically, all I need to do is pass off a string and call a GWT method. The method (when called from GWT and not handwritten JS) works perfectly. I have also verified that the exposed method will fire a simple alert. I believe the problem lies in calling the other classes' methods.
I get: "(TypeError) Unable to get property 'hv' of undefined or null reference description."
Is there a way to pass off a string to the original GWT method without having to go an expose the countless other methods that it will eventually run through?
I personally haven't thought about the static vs instance methods and JSNI, although it seems that there might be uses for both to be pushed out to the window.
One situation where I've used this concept is in apps that are popups, which going to be hosted in other sites' pages and invoked via a click on one of their page elements. I have no control over their page structure, and even asking for an element with an id that I could wrap as a widget is a bit more than I'd like to do. If I can just tell them "Add onclick='xyz()' to whatever page element you want to be the trigger, that leaves them free to design the page as they see fit, using an a tag, img tag, etc. as the trigger. I can then push the function that shows the popup out to $wnd.xyz.