Hi Filippo,
Yes, it's certainly practical to integrate JavaScript within your GWT code.
Take a look at the Google Search and Google Video Search applications that comes with the book's main example (
http://dashboard.manning-sandbox.com and then select the Create Menu). These example use JSNI to communicate from GWT to Google JavaScript libraries.
Whilst it is possible, you do have to think of the reasons why you would.
The main reasons for using JSNI are two-fold:
1) You need to use a JavaScript library that you cannot rewrite in GWT (e.g. you don't have the license; you don't have the desire to,...).
2) You need to do something that is not currently provided by GWT.
I don't think it is sensible to advocate putting large amounts of JavaScript within an application except for those two reasons. To do so, you would:
* not benefit from the static analysis of GWT compiler (so your code would be larger than necessary - GWT compiler very aggressively removes unused Java code),
* not leverage off the browser agnostic approaches within GWT (so code would either be larger with included code for browser sniffing/browser versions, or not work in one/more browsers),
* not be able to take advantage of the typing model of Java (so potential for errors / tougher debugging creeps in)
The principles of JSNI are fairly straight forward - it effectively hijacks JNI syntax for methods and then introduces some syntax to represent Java objects in your JavaScript code.
The chapter in the book talks through the key components of JSNI covering writing JavaScript in your code; talking to JavaScript libraries; getting JavaScript libraries to talk back to GWT applications; passing objects over the boundaries; and implementing an API to your application through JSNI. This is then backed up by complete implementations in the example application.
Your final question is also interesting! There is a danger when writing a GWT application to forget the actual client side Java code will be implementated in JavaScript. If you look on the GWT forum there are often questions about accessing a user's hard drive; directly accessing a database; client side logging (e.g. Log4J file output) - stuff that is not too unusual to think of in a Java program, but not necessarily possible in JavaScript. That said, as long as you remember your code will eventually become JavaScript, it is a comforting development experience.
Hope the answer to your questions are in there - naybe I should start writing shorter answers!!
//Adam