Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Problem with understanding the general concept.

Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm pretty new with GWT but I have read on already quiet a lot and tested as well. In general GWT translated the Java code that we write into Javascript. That's straightforward. But in the sample application, I have a file war\MyCoolApp.html in which there is an html structure:

which further is used in Java code to place the elements:
(from src\com\oi\gwtex\client\


And now is my questions how these two things mix? At the beginning I thought that the main html page will not contain anything in the body and everything will be done by the script that is loaded before everything else. But now it seems that the script is loaded and further the html structure is rendered on it's own as well. Can someone explain me this in more details please?

Posts: 11445
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of the ids you define in your html as place holder, or co-ordinates if you will. If you look at the source of your rendered GWT application, you will notice these ids in it. When the script executes, it gets these IDs, and places your widget there, eg. nameField or sendButton.

It is true many applications are pure GWT only. I personally prefer it that way because I am HTML/CSS challenged and I come from a Swing background. So I find writing "pure" GWT apps much easier.
However, there are certain advantages to mixing HTML and GWT (using the RootPanel.get("id")) .
1) Your page has lots of static content but only a few dynamic content. E.g. a site which offers currency conversion. Static content would contain stuff like who we are, what we do, how much we charge, how to contact us etc. Dynamic content would be just a small widget, which displays the very current currency conversion rates. These rates would keep on changing the whole day. So it makes sense to have a widget display them.
2) Same as above, but with changing static content. Consider coderanch. This very site. Whenever you load it, it shows the forums sorted by latest posts. The content changes dynamically, but not that frequently, meaning it is not a "live update". In such cases, it makes sense to have a servlet serve this content. Now consider a widget which tells you if anybody replied to your post, or if anybody updated a thread you are watching. Again a widget would be useful in displaying this information.

GWT offers you the flexibility to mix and match. It is up to you as a developer to choose how to approach it.
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic