0

I'm trying out developing a game for facebook, and I'm trying a "Publish to Timeline" feature through the js-sdk. My codebase is java, using lib-gdx, and the problem is, I don't know how I can invoke my js function that show the "Publish to Timeline" prompt. What could be the right way of doing it? I've tried this one as described here, but doesn't work:

public static native void publishFeed(int score) /*-{
publishFeed(score);
}-*/

2 Answers 2

3

GWT code (generally) runs in an iframe, so the (global) scope of the JSNI code (window) is not the same as the one of the so-called HTML Host Page. That one is called $wnd.

public static native void publishFeed(int score) /*-{
   $wnd.publishFeed(score);
}-*/;
Sign up to request clarification or add additional context in comments.

1 Comment

This is no secret. Straight for the doc: “When accessing the browser's window and document objects from JSNI, you must reference them as $wnd and $doc, respectively. Your compiled script runs in a nested frame, and $wnd and $doc are automatically initialized to correctly refer to the host page's window and document.” and knowing that window == global scope is JS 101.
0

IUnknown::QueryInterface in Java

Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class. The Object::getClass() method returns ‘Class’ which has many useful functions to discover the details of the Java class itself. While a detailed explanation is beyond the scope of this article, I would like to point out the getInterfaces() method that enables dynamic discovery of the interfaces implemented by a Java class.

I have not tried invoking the getClass() method from within JavaScript and hence cannot comment on it’s feasibility. But using an infrastructure type applet, this functionality can be easily made available to scripting code.

check this link hope you get what your looking for

http://www.codeproject.com/Articles/571/Java-to-JavaScript-Communication

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.