Passing parameters from JSP to GWT Entry Point

1,033 views
Skip to first unread message

Sumved

unread,
Oct 23, 2008, 10:47:10 PM10/23/08
to Google Web Toolkit
Hi All,

I am wondering whether we can pass parameter from JSP to GWT Entry
point.
I hope it is there because in real scenario probably no-body will use
only GWT.

Like, I have integrated Struts with GWT.

Now, My question is, Can we pass a value from JSP to GWT Entry point?

Thanks in advance.

Regards,
Sumved Shami

Daniel Kurka

unread,
Oct 24, 2008, 1:48:27 AM10/24/08
to Google-We...@googlegroups.com
you can write a javascript variable to the page like

var request = { myparam : "test", second : "test1" };

and read that with the GWT Dictionary

2008/10/24 Sumved <sumved...@gmail.com>

olivier nouguier

unread,
Oct 24, 2008, 3:43:16 AM10/24/08
to Google-We...@googlegroups.com
Hi,
GWT lives in client space so :

* Simple way:

In your jsp:
<script>
var myVar = "<%= (String)session.getAttribute("myVar") %>";
</script>

And in your module :

JNSI.getString("myVar", "defaultValue");

with the JNSI class:

public class JNSI {
 public static native String getString(String jsVar, String defaultValue)/*-{
      var value = eval('$wnd.'+jsVar);
      if(value){
        return value;
      }
      return defaultValue;
    }-*/;
}

*  more complex  :

Define some API in your GWT module by hand or with something like GWT Exporter (http://timepedia.blogspot.com/2008/06/preliminary-gwt-export-20-release.html):

ie: module provides setMyVar(String method)

call your api from JSP page **after the module sas started**

<script>
function gwt_callback_called_by_gwt_module_onLoad(){
  setMyVar("<%= (String)session.getAttribute("myVar") %>");
}

HTH
--
Si l'ignorance peut servir de consolation, elle n'en est pas moins illusoire.
Reply all
Reply to author
Forward
0 new messages