At some point in your GWT development, you’ll want to start communicating with a server. Handily, GWT has a lot of stuff built in to help you do this in as easy a way as possible. The GWT RPC framework is very helpful indeed for just this, and this post will show you how to create your RPC services easily. The basics:
GWT is divided into “client-side” and “server-side” interaction. “Client-side” is what’s done by the browser, and “server-side” is obviously what’s being done by the server. Server-side is what can’t or shouldn’t be done in the browser. It helps to think of the client-side as the frontend and the server-side as the backend, though this isn’t always the correct view to take.
GWT-RPC is essentially very easy client-server interaction. Create a few interfaces, edit an xml file, write a little code, done. Client-side code will be compiled by GWT into Javascript, and server-side code will be compiled into Java bytecode, meaning that you’re programming pure Java on the server-side, so you can use all kinds of native Java libraries that you couldn’t otherwise. How to build a service into your GWT app:
This is a somewhat long one, so make yourself a cup (or seven cups) of coffee. Here’s the code for this tutorial, if you feel like just looking at code.
Make sure before you do this that you’re set up properly, with a blank project as detailed in this tutorial. However, the example that’s created by default makes use of RPCs, so if you just want a rough idea on how it works, have a look at that.
Alright, let’s get going.First, let’s create the client-side interface to our service which lists all the RPC methods.
Right-click ie.flax.RPCTutorial.client (in my case) and select “New -> Interface”. Read more: Flax
GWT is divided into “client-side” and “server-side” interaction. “Client-side” is what’s done by the browser, and “server-side” is obviously what’s being done by the server. Server-side is what can’t or shouldn’t be done in the browser. It helps to think of the client-side as the frontend and the server-side as the backend, though this isn’t always the correct view to take.
GWT-RPC is essentially very easy client-server interaction. Create a few interfaces, edit an xml file, write a little code, done. Client-side code will be compiled by GWT into Javascript, and server-side code will be compiled into Java bytecode, meaning that you’re programming pure Java on the server-side, so you can use all kinds of native Java libraries that you couldn’t otherwise. How to build a service into your GWT app:
This is a somewhat long one, so make yourself a cup (or seven cups) of coffee. Here’s the code for this tutorial, if you feel like just looking at code.
Make sure before you do this that you’re set up properly, with a blank project as detailed in this tutorial. However, the example that’s created by default makes use of RPCs, so if you just want a rough idea on how it works, have a look at that.
Alright, let’s get going.First, let’s create the client-side interface to our service which lists all the RPC methods.
Right-click ie.flax.RPCTutorial.client (in my case) and select “New -> Interface”. Read more: Flax
0 comments:
Post a Comment