Particularly, I would like to know how a GWT app is deployed. For
example currently I have a non-Ajax Java Servlet which will based on
several db parameters and what's sent from the client, will build up a
page dynamically and send it back out to the client.
Now I'm not sure if this is the case but from what I understand the GWT
way of doing this is building the page as if it is an application
including everything in the one page it will need to run. Then via
ajax and client side javascript have the client decide what the page
needs and request it asynchronously to fill the page. So basically the
page decides what it needs and gets it from the server, almost the
opposite of the previous approach.
I'm wondering if GWT allows/ is meant for a cross between the two where
the servlet will build up a page and dynamically add gwt and other
components as needed.
Also are there any good tutorials for something like this. I've seen
million hello world, start a new project type tutorials but none about
how to extend functionality to already built servlets, which is why I'm
assuming GWT wasn't built for that purpose.
(the short version... not trying to be sarcastic)
1. The HTML page loads
2. Your JavaScript loads (which had been compiled from Java)
3. The JavaScript executes and does stuff.
> Particularly, I would like to know how a GWT app is deployed.
Assuming you don't use RPC... then it is just some HTML/JS files that
you drop on your system. Once the Java code is compiled to JavaScript,
it works anywhere JavaScript works. No app server required, and it will
even run locally without a web server.
> from what I understand the GWT way of doing this is
I don't believe that there is (or should be) a "GWT way". GWT can be
used, as you mentioned, for building full stack applications, but it
can also be used as a glue language to manage pure JavaScrtip
libraries. As for RPC it can communicate with Java app server using
GWT-RPC, or with Perl/PHP/Ruby/(pick your language) servers using JSON,
or lAjax style loading of XML or HTML.
I suggest forgetting about the GWT way, and focus on the specific
problem that you are trying to solve. If you can explain how you would
solve a problem with JavaScript, then it can be mapped to a GWT
solution.
> I'm wondering if GWT allows/ is meant for a
> cross between the two where the servlet will
> build up a page and dynamically add gwt and other
> components as needed.
Maybe you should think of GWT as allowing you to write client-side code
in Java instead of JavaScript. In that case the question is, what does
the code need to do on the client side?
Perhaps you want a clock on the page, or a tabbed pane, or form
validation?
Rob
> I'm wondering if GWT allows/ is meant for a cross between the two where
> the servlet will build up a page and dynamically add gwt and other
> components as needed.
no, this is not the case. You should use GWT to build a new client for
a servlet. Such a client will access the service implemented by the
servlet through asynchronous RPC (Remote Procedure Call).
To get GWT-enabled, some <YourService>Impl servlet just needs to extend
RemoteServiceServlet and implement the outside view of the service it
offers as specified in the <YourService> interface.
In the DynaTable sample, you'll see, for example:
public class SchoolCalendarServiceImpl extends RemoteServiceServlet
implements
SchoolCalendarService {...}
Here, the client will call the servlet public method to retrieve the
schedules of both students and professors at the server-side. The
DynaTable sample is a good starting point for those who want to use
servlets with GWT clients.
Hope this helps,
Cristina
I recently used it to figure out how much http traffic goes on with gwt
in hosted mode. You need to use the -noserver mode for the GWTShell so
that you can place TCPMon between your gwtshell and the external http
server (Tomcat in my case).
Say your site is at http://mysite.com, on port 80. Then fire up tcpmon
like this
tcpmon 16867 http://mysite.com 80
where tcpmon is also running on host mysite.com
and then launch gwtshell pointing to tcpmon
gwtshell http://mysite.com:16867/path/to/gwt/hostpage
Stuart
Yes, this is what we do. The point is that we let our regular servlet
build a page with an IFRAME on it, which then has its "src" set to the
deployed GWT app, which we will copy to the static part of our
application (served by Internet Information Server) in the same form it
has in the www compiler output folder.
The point is that the servlet that generates the page, only creates the
IFRAME, some javascript to set window-variables, and some javascript to
set the "src" of the IFRAME when ready. It does NOT create DOM
components for the GWT app to interact with. The GWT app picks up the
window variables set by autogenerated code, and then manages its own
GUI inside the frame.
Should the GWT app have to naviagate to another page within the app as
seen from the regular servlet, it would have to reload the page, having
the servlet build a new page, following the pattern above. Most likely
it would refer to the same GWT application, as it would be a pain to
have several GWT apps. Rather, a single GWT app that is told via
window.xxx (javascript values) what functionality to show.
See also
http://groups.google.com/group/Google-Web-Toolkit/browse_frm/thread/aa19897c3313c5a3
:-)