Reputation: 2633
I'm new to GWT. I'm using the eclipse to create a simple application. After understood the basics like, how to run the project in development mode and production mode but one thing i'm unable to understand. In google they given a sample build project, when i finished with that i seen one more tutorial called RPC in GWT. Here they changed the previous code and implemented the new one. In GWT everything is converted into the javascript but when we are using the RPC, then RPC(server) code will be in the java bytes format at server. My question is why we have to implement the RPC? What's the need to use RPC?
Upvotes: 1
Views: 253
Reputation: 62185
The need to use RPC is to let your Client communicate with the server via asynchronous calls. RPC abstracts this call in a way so that calling a method on a server is analog to calling a method on a normal object. So, calling a local method and calling a "remote" method becomes basically the same.
(Of course, you could also write client code which never calls a server.)
Upvotes: 3
Reputation: 3571
Well imagine that you want to call an operation that is implemented on the server side, for example login a user.
There is a database of registered users on the sever. The clinet (javascript code in browser) must send the name and password of the user to server. The server (java code) then contacts the database and authenticates the user and returns a true or false back to client. This way you have romotely called an operation (the login procedure) on the server from client, and got a response back. Hence the name RPC.
The key here is to understand client side and server side. On the client side you have javascript, but with java script you cannt access a database. Additionally you don't have the databse of all registered users on every client (browser). So you have the server side that contains the databse and also the java code to connect to this database. Each client just tell the server to do the corresponding operation via RPC and gets the result back.
Upvotes: 1