• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with understanding the general concept.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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\MyCoolApp.java)

RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);


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?

Cheers,
Jan.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic