I'm following the example given here
https://developers.google.com/web-toolkit/articles/dynamic_host_page of
passing a global info javascript variable back to the GWT app when it
loads. E.g.
// In GwtHostingServlet's doGet() method...
writer.append("<html><head>");
writer.append("<script type=\"text/javascript\"
src=\"sample/sample.nocache.js\"></script>");
// Open a second <script> tag where we will define some extra data
writer.append("<script type=\"text/javascript\">");
// Define a global JSON object called "info" which can contain some simple
key/value pairs
writer.append("var info = { ");
// Include the user's email with the key "email"
writer.append("\"email\" : \"" + userService.getCurrentUser().getEmail() +
"\"");
// End the JSON object definition
writer.append(" };");
// End the <script> tag
writer.append("</script>");
writer.append("</head><body>Hello, world!</body></html>");
Then in my GWT app's EntryPoint class I have:
public static native String getEmail() /*-{
return $wnd.info['email'];
}-*/;
However when the app runs I get an exception saying:
$wnd.info is undefined
I've tried $doc but got the same error. I also tried window and document
but then it says document.info is undefined. What am I doing wrong?
-Dave
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/y9lEftpPeUcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.