• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GWT JSNI method exposure

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're running into the slippery nature of "this" in JS.

Try:


I wrote this based on your code from working code I have - hopefully I transmuted it to your case correctly.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
If you are invoking static methods, why JSNI? Any particular reason, why you do not wish to invoke them from your java code?
 
steve claflin
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic