Making non-scripted pages with GWT

6 views
Skip to first unread message

treeder

unread,
Apr 18, 2007, 4:36:22 PM4/18/07
to Google Web Toolkit
I've been building a couple GWT apps over the past six months and
although I really love working with gwt, I still wish I could generate
good old static pages (well not quite static, but non-scripted). For
instance, lets say on the first load of my app, I want the user to see
a fully laid out page including content without any use of javascript,
just like this discussion group for example. From that point on, I
would then like to modify/update the page with javascript/AJAX just
like GWT allows you to do now. So I am just talking about that initial
page load.

Now I know this can be done using jsp and adding GWT to the jsp page,
but then I don't get to use the GWT components and the great things
that GWT brings to the table in terms of UI building. I would have to
build the initially loaded page using something else (maybe just
straight up writing html, or use some other framework) and then on top
of that, I could use GWT to work with the page elements after they are
loaded.

Now you may ask why someone would want to do this, and you might say,
well that's not what GWT is made for, but it really limits the
usefulness of GWT if it can't be used in scenarios like this.
Examples: Wiki's, stores/ecommerce systems, social sites, etc. All of
these need to have non-scripted content pages for search engines to
crawl them, they need to have unique URL's for every page and they
need to make the initial page load way faster than the initial load of
a GWT app.

So as for how it could work, it might be something like this:

Your EntryPoint (or a new subclass of EntryPoint) could have another
method such as:

public void onInitialLoad(HttpServletRequest request){
// This method would execute and be written as the original page
request.
// From the request parameter, we could get the URL and query
parameters
// and return the appropriate content, all while being able to use
GWT to build
// the UI.
// Also, the objects created and used here would be sent to the
// client onModuleLoad for a seamless experience.
}

I realize this type of feature would require a Java app server in
production, but this can be an optional feature, just like the RPC
calls, so that shouldn't be a big deal.

Thoughts?

krispy

unread,
Apr 19, 2007, 9:03:16 AM4/19/07
to Google Web Toolkit
treeder,

It seems to me that nothing would stop you from doing this - you can
create as many items as you want inside of the body of your page, then
access them from GWT with DOM.getElementById(String id). I think that
you'd just create your webpage in some other environment, then create
a GWT project for it, populate all your panels by calling the DOM and
then go ahead and manipulate! you can create a root panel by using
RootPanel.get(String id) on some item you create to encompass your
app (even make it an <iframe> like GWT does). Maybe I'm confused, but
it seems like there's a lot of good support in GWT for taking existing
web pages and converting them into an AJAX/DHTML app - or am I missing
the point of your post?

-krispy

treeder

unread,
Apr 19, 2007, 6:59:24 PM4/19/07
to Google Web Toolkit
Krispy, thanks for the response, but I think you're missing the point.
I want to avoid creating the "existing page" using another technology.
It would be nice to be able to build the initial/existing page using
GWT components which would require those components to be written out
as xhtml initially, not using the client side DOM.

Travis

> > Thoughts?- Hide quoted text -
>
> - Show quoted text -

theClassConnection

unread,
Apr 19, 2007, 8:22:57 PM4/19/07
to Google Web Toolkit
Possible solution: Use GWT as normal to create an entirely scripted
page. Interact with the page however you'd like to, until the page is
exactly how you would like your static page. Then, using web
developer tools (I have toolbars in firefox and IE that would be
sufficient...) view the generated source. You should be able to save
that and have the exact HTML required to render that static page. You
WILL LOSE your javascript state at this point. Additionally, you will
need to replace your GWT script with a script that expects to start
from this static page, unless your first script analyzes the html it
is embedded in before modifying it. (If you don't, and your original
script creates a couple of divs, running that script from the new
static page will result in duplicate divs being created.)

I can't think of a good way to do all of this in an entirely automated
manner, but I believe there is a very good reason for that... GWT !=
Dreamweaver. No, really, THEY MAKE TOOLS TO DESIGN STATIC PAGES.
These tools, when used by someone who knows what they are doing (or at
least willing to learn what they should be doing), will make BETTER
code than the GWT output. [I'm not trying to insinuate that GWT
output code is bad, just that table-based layouts tend to be heavier,
more hacked-together, and less robust than standards based layouts;
especially when the tables are generated by a framework that needs to
be able to output an arbitrary layout.] I love GWT dearly. Without
it, I wouldn't have a job, and our website (still in development)
would be years away from what we can do now. That doesn't mean I want
to use it for everything. Much like no screwdriver, no matter how
good at driving screws, will be a very good hammer; GWT just isn't a
good static page layout tool.

-Joshua Yanchar

Reinier Zwitserloot

unread,
Apr 19, 2007, 9:49:36 PM4/19/07
to Google Web Toolkit
Joshua, I totally agree that GWT isn't exactly dreamweaver. Be that as
it may, there are plenty of good reasons to make a tool that can
'compile' GWT to HTML.

For example, a page that gets loaded when a non-GWT compatible browser
is found, or, in certain circumstances, when the thing you need to do
is so basic, even the 100k or so of GWT are overkill.

Fortunately, something similar to this already exists:

http://www.kisgergely.com/gwt-server

http://code.google.com/p/gwt-html/wiki/Release_0_1

I haven't looked closely at these tools yet, though.

On Apr 20, 2:22 am, theClassConnection <theclassconnect...@gmail.com>
wrote:

treeder

unread,
Apr 24, 2007, 12:12:28 AM4/24/07
to Google Web Toolkit
Thanks for the links! I will check that out.

Has anybody tried this gwt-html project?

Travis

> > -Joshua Yanchar- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages