java - Question about Google Web Toolkit (GWT) and pre-processing of dynamic data in HTML page -


i'm new gwt , new doing java web development, using spring mvc, , wondering if can clarify me have been searching extensively still not clear on this. when doing php / javascript development use php dynamically populate within javascript (such javascript variable) on page load. seems me not done gwt , instead gwt app deployed user's browser , gwt client side app makes rpc calls retrieve necessary data... right dynamic data isn't put gwt page on page load?

i appreciate clarification on have spent lot of time looking , don't want keep trying (the dynamic data in gwt code on page load) if not possible or not idea. thanks

gwt apps output html, can page before or while gwt app running.

for example gwt app declare native js code this:

  private native dosomething() /*-{     dosomethingjs();   }-*/; 

where dosomething() called gwt app @ runtime , in turn invokes js function called dosomethingjs() (manipulate dom, popup dialog, validate field, whatever).

your html file gwt app define function or pull in externally. generate html file on fly using php or jsp if wished.

for example, use jsp file generate app's landing page, define dosomethingjs(), embed expression, or css hack or whatever, e.g.

<%@ include file="taglibs.jsp" %> <%@ include file="nocache.jsp" %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>my application</title> <script type="text/javascript"> function dosomethingjs() {   window.alert("hello ${some.element.name}!"); } </script> <script type="text/javascript"     src="com.myapplication.nocache.js"></script> </head> <!--[if lt ie 7 ]> <body class="ie6" id="ie6hack"> <![endif]--> </div> </body> </html> 

the above means can avoid roundtrips if want. example, gwt app needs know user's email address don't want take hit asking server @ startup.

we define native method:

private native string getemailaddress() /*- { return emailaddress; } -*/; 

and our jsp contain such as

<script>   var emailaddress = "${user.emailaddr}"; </script> 

so save round trip because data embedded right there in html , available app.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -