GWT - All or none?

144 views
Skip to first unread message

Jeff Britton

unread,
Jan 18, 2008, 9:42:46 AM1/18/08
to Google Web Toolkit
We are considering using GWT on a project within my company. Our
application is based on the spring/pojo framework and makes use of
many ajax features. Our existing code base contains a lot of UI code
(JSP/Javascript/Tag Libraries) that we would prefer not to rewrite.
We would like to use many of GWT's features but we are not sure if GWT
can be used to generate portions of the page rather than the whole
page. Is there a way to embed GWT content within a DIV tag of a JSP
page, for example? If anyone can shed some light on this, it would be
greatly appreciated.

Thanks,
Jeff Britton

Isaac Truett

unread,
Jan 18, 2008, 9:52:57 AM1/18/08
to Google-We...@googlegroups.com
Yes. Just use an ID for inserting your GWT content:

public void onModuleLoad() {
RootPanel.get("someId").add(new YourGwtWidget());
}

The rest of the page is left untouched.

Casey

unread,
Jan 18, 2008, 10:52:50 AM1/18/08
to Google Web Toolkit
How do you define different GWT widgets across multiple existing
pages ? Do you need to create a separate module for each page/gwt
component or a separate project for each page/component?

On Jan 18, 9:52 am, "Isaac Truett" <itru...@gmail.com> wrote:
> Yes. Just use an ID for inserting your GWT content:
>
> public void onModuleLoad() {
> RootPanel.get("someId").add(new YourGwtWidget());
>
> }
>
> The rest of the page is left untouched.
>

Isaac Truett

unread,
Jan 18, 2008, 11:12:33 AM1/18/08
to Google-We...@googlegroups.com
Many approaches could work. One would be to create a single module
where the entry point checks for multiple IDs on the page and inserts
a widget into any that are found (i.e., RootPanel.get("someId")
doesn't return null). One of the advantages to this approach compared
to multiple modules is a one-time download upfront that gets loaded
from cache as the user navigates between pages.

Jason Essington

unread,
Jan 18, 2008, 12:39:21 PM1/18/08
to Google-We...@googlegroups.com
sure, that's how GWT works.

RootPanel.get("someId").add(someLayout);

that is the basic way to deal with adding gwt bits to any page,
whether rendered from JSP or static html, or some other server side
technology.

you can have multiple modules all doing different things on the page
as well.

basically if you can conceive of doing something with javascript, GWT
can do it as well.

-jason

Charlie Collins

unread,
Jan 19, 2008, 9:51:25 PM1/19/08
to Google Web Toolkit
I have previously used the same approach Isaac suggests in some tests,
when asked this same question, and it seemed to work pretty well.
Disclaimer: I have never used this with a big production app, only
some proof of concept stuff.

Using a single module gets you one download, nice. Then each page
loads that module, and in my case I used a Dictionary to set a name/
value pair on each page, pageId/whatever. Then the EntryPoint loads
the dictionary and using a a big case/switch fires off the needed
widgets for the current page (and places them inside a particular div
or divs, using the elementId).

Something like this:

Host Page:
http://totsp.com/svn/repo/MultiPageExample/trunk/src/main/resources/com/manning/gwtip/example/public/page1.html

Entry Point:
http://totsp.com/svn/repo/MultiPageExample/trunk/src/main/java/com/manning/gwtip/example/client/MultiPageExample.java

If anybody has used this in the wild on a prod app, or any other
approach to integrating widgets on a site that already has a bunch of
pages, I would like to hear about what did and did not work.

(You could also do the module per page thing, and each module could be
stupid simple, re-using the same code base for the widgets, but then
every page would have to download a new module, that's less than
ideal.)


On Jan 18, 11:12 am, "Isaac Truett" <itru...@gmail.com> wrote:
> Many approaches could work. One would be to create a single module
> where the entry point checks for multiple IDs on the page and inserts
> a widget into any that are found (i.e., RootPanel.get("someId")
> doesn't return null). One of the advantages to this approach compared
> to multiple modules is a one-time download upfront that gets loaded
> from cache as the user navigates between pages.
>
Reply all
Reply to author
Forward
0 new messages