Private native void publish(EntryPoint p) /*-{ $wnd. SetText = function(from) { alert(from); p. @com.example.my.
Class::helloMethod(Ljava/lang/String;)(from); } }-*/; Could you give a try this code?
Very nice - I think I prefer this over the var that = this syntax. – Carl Mar 8 at 17:21.
Method is an instance method, and as such it requires the this reference to be set, when it is called. Your first example doesn't do this at call time. Your second example attempts to do this, but there's a little mistake, which one can make easily in JavaScript: The this reference in $wnd.
SetText = function(from) { this. @com.example.my. Class::helloMethod(Ljava/lang/String;)(from); } points to the function itself.To avoid this, you'll have to do something like: var that = this; $wnd.
SetText = function(from) { that. @com.example.my. Class::helloMethod(Ljava/lang/String;)(from); } Or better: var that = this; $wnd.
SetText = $entry(function(from)) { that. @com.example.my. Class::helloMethod(Ljava/lang/String;)(from) }).
Chris, thanks - both your corrections work like a charm. You say the second one is better - can you clarify why? – Carl Mar 8 at 17:19 @Carl: Sure, the dev guide on JSNI says about $entry: "This implicitly-defined function ensures that the Java-derived method is executed with the uncaught exception handler installed and pumps a number of other utility services.
The $entry function is reentrant-safe and should be used anywhere that GWT-derived JavaScript may be called into from a non-GWT context. " BTW, the var that = this; line is a typical JavaScript idiom (see eg this article). – Chris Lercher Mar 8 at 18:43 weeell, I was hoping you'd actually explain what that quote from the dev guide meant (I'd already read it).
I'm familiar with the var that = this; idiom, but going with @ykartal's solution makes it possible to make publish static - usually an early step towards being able to generify/extract/otherwise relocate methods. – Carl Mar 8 at 19:02 @Carl: I'm awful at mind reading over the internet. I'm a little bit hesitant now to explain the uncaught exception handler, if you understand... In any case, this would deserve a separate question.
– Chris Lercher Mar 8 at 19:18 +1: expect the unexpected if you don't use $entry! – funkybro Mar 87 at 7:38.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.