90 likes | 246 Views
Your new desktop: Web 2.0. Google Web Toolkit server side java libraries that emit javascript and html. Google Desktop Gadgets. Gmail. GWT. An open source Java software development framework. Front-end (client) code is written in Java and compiled to JavaScript and HTML.
E N D
Your new desktop: Web 2.0 Google Web Toolkitserver side java libraries that emit javascript and html
GWT • An open source Java software development framework. • Front-end (client) code is written in Java and compiled to JavaScript and HTML. • Back-end (server) Java code is compiled to servlets. JavaScript Client Java Code GWT Compiler HTML Server Java Code Java Compiler Java Servlet
Dynamic UI Support • com.google.gwt.user.client.ui • Source code: similar to Swing and SWT • DOM, dynamic HTML will be manipulated through JavaScript generated from GWT Java code • class com.google.gwt.user.client.ui.FlexTable setText(0, 0, “Amelie”) <table> <tr> <td>Amelie</td> … </tr> … </table>
Remote Procedure Call public interface MovieService extends RemoteService { Movie[] getMovies(int start, int count); Movie getMovie(String id); } public interface MovieServiceAsync { void getMovies(int start, int count, AsyncCallback callback); void getMovie(String id, AsyncCallback callback); } Client side Server side Calls MovieServiceAsync RPC MovieList MovieServiceImp MovieService Implements
Two modes • Hosted mode • Client side: Google hosted browser – interprets Java code • Server side: embedded Tomcat Server – Servlet classes (uses Java compiler) • Web mode • Client side: web browser (i.e., Firefox) – JavaScript and HTML (uses Java2JS compiler) • Server side: Tomcat Server – Servlet classes (uses Java compiler)
Using Servlet Objects class com.google.gwt.user.server.rpc.RemoteServiceServlet { protected final HttpServletRequest getThreadLocalRequest() protected final HttpServletResponse getThreadLocalResponse() } e.g. using Servlet Session Objects HttpServletRequest request = getThreadLocalRequest(); HttpSession session = request.getSession();