Tuesday, August 11, 2009

Passing Parameters in GWT RPC (Client-side)

Continued from GWT RPC


The GWT RPC tutorials provide the simple case of passing and receiving String objects. However, in most, if not all, practical cases, programmers need to pass a set of parameter-value pairs between HTTP communicants. In this case, between communicants of the communion of RPC over HTTP.

TableMgr bears in itself an example how to pass parameters over the RPC/GWT/HTTP (RPC over GWT over HTTP) communion.

For TableMgr source code, refer to
http://code.google.com/p/synthfuljava/source/browse/#svn/apps/GData Table Manager,

and for the library elements it uses, refer to
http://code.google.com/p/synthfuljava/source/browse/#svn/trunk.

Do not copy code from this page, as it would contain line-breaks and exclude lines left out for brevity that would break the code, but get them drectly from the google code project listed above.

TableMgr uses a HashMap as the datatype being passed. A HashMap is the best choice because it allows values to be mapped to parameter keys.


GWT client-side code
package org.synthful.gwt.http.servlet.client;
import java.util.HashMap;
import com.google.gwt.user.client.rpc.RemoteService;

public interface HashedParameterService
extends RemoteService
{
 String doServiceResponse(
  HashMap<String, String> input);
}

The interface HashedParameterService is a generic service declaration interface (provided by the courtesy of this author) which anyone could use, but if you use it with GWT-provided server side RemoteServiceServlet, your servlet would need to provide the method

String doServiceResponse(
 HashMap<String, String> input);


GWT applications in accessory to using this framework is restricted to having this method as the RPC procedure being called.

Or, you could copy it and rename the method to a name of your liking. However, my intention for it was not to provide a generic service declaration interface, but for a more sinister intention. It is to subvert the RemoteServiceServlet provided by GWT so that I could have JSPs, rather than plain servlets, implement it to service RPC requests. This would be explained later in the server-side part.

Wait a minute, shouldn't the service declaration interface contain the RemoteServiceRelativePath directive to tell the GWT compiler the URL that would service its RPC request? Therefore, to keep this interface generic, we introduce an extra layer of interface.
package com.blessedgeek.gwt.gdata.client;
import
org.synthful.gwt.http.servlet.client.HashedParameterService;
import
com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("TableActionService.gwtrpc.jsp")
public interface TableMgrService
 extends HashedParameterService
{}


TableMgrService would be the actual interface implemented by the RPC client, but the server side would still implement its super-interface HashedParameterService. The corresponding client and server sides do not actually have to implement the same interface but interfaces of the same signature.

The companion async-response request interface to that is

package org.synthful.gwt.http.servlet.client;
import java.util.HashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;

/*
* @gwt.TypeArgs parameters <java.util.HashMap 
<java.lang.String,java.lang.String>>
*/
public interface HashedParameterServiceAsync
{
 void doServiceResponse(
  HashMap<String, String> parameters,
 AsyncCallback<String> callback);
}


Note that both of them declares the same HashMap<String, String> parameters argument.


Continue next Passing Parameters in GWT RPC (Server-side)

21 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete
  2. Ce sac cartable Michael Kors est si universel qu'il pourrait plaire à tout le monde. Dans cet article, je vais essayer de passer en revue les caractéristiques principales et les éléments qui distinguent ce sac à main des autres.

    tags:Bolsos Michael Kors Rebajas,Bolsos Michael Kors Baratos,Bolsos Michael Kors El Corte Ingles

    L’extérieur de ce fourre-tout Michael Kors est un cuir métallisé de laiton froncé et froncé. Si vous connaissez les sacs à main Michael Kors, vous savez que ce cuir sera doux et souple. Les deux grandes poignées supérieures sont attachées au sac avec quelques centimètres de chaînes dorées, puis les moitiés supérieures des bretelles présentent le même cuir couleur laiton.

    tags:Bolsos Michael Kors Baratos,Michael Kors Örhängen

    La diversité des couleurs et la taille utilisable de ce sac le rendent parfait pour un usage quotidien. Les poches intérieures ne manquent pas pour aider à garder les choses en ordre. Il y a des endroits parfaits pour votre téléphone ou votre Blackberry. Le zip top empêche les malfaiteurs de saisir votre sac dans un bar et aide également à contenir tout ce qui se trouve à l'intérieur lorsque vous courez pour créer ce train.

    tags:Windguru Longchamps,Longchamp Soldes Destockage,Pronote College Longchamp

    ReplyDelete
  3. Michael Kors Outlet Online was a huge success there and became very well known. The designer Kors then branched out into accessories including Michael Kors Handbags Clearance. He never lost focus on his American chic styling. Some of his most notable collections include the Michael Kors Totes, Michael Kors satchel and the Designer MK Outlet and Michael Kors Outlet Online Store.

    No one has to know that they are cheap Ray Ban Sale UK and no one will know unless you tell them. Each of the cheap designer Ray Ban Sunglasses Sale UK carries the signature brand on the lens to let you know that you do have authentic designer Cheap Ray Ban Sunglasses UK.

    tags: Cheap Oakley Sunglasses UK,MK Outlet

    ReplyDelete
  4. As well as the cars used by furniture moving company from Jeddah to Dammam, it is a number that means that the company can move any amount of luggage even if this amount is too large and difficult to move from one place to another, the company will ensure that you do so.

    شركة نقل عفش
    شركة نقل عفش من الرياض الى الاردن
    شركة نقل اثاث من الرياض الى الاردن
    شركة نقل عفش ببريدة

    ReplyDelete
  5. Jordan 1 Og Black Friday, Is this a utopian city vision that offers people a dreamlike future existence? Or, do we need to focus more on aligning the technological promise with the very human nature that lies behind the beating heart of our cities. Surely, it is really all about people and our collective quality of life. How accessible are smart solutions to those living in poorer areas or without digital literacy?.

    The younger Boselli played in 10 games as a junior in 2019, including starts vs. {tag: Yeezy Boost 350 V2 White Black And Red}I haven't talked to anyone yet,'' Rose said. {tag: Yeezy 750 Black White Sole}"

    Sign up to FREE email alerts from Mirror Royal FamilySubscribeWe will use your email address to send you newsletters. {tag: Bone White Yeezy 500 Release Date}Everyone plays a critical role in protecting others.Here's the latest from ADPH as of April 7:2,007 laboratory cases. {tag: Cloud White Yeezy 350 On Feet}

    Air Jordan 1 Black History Month 2016, Hawaiian tourism groups will pay to fly visitors who violate self quarantine rule homeHawaii tourism industry, which normally welcomes tourists to the popular vacation destination, is offering visitors whodisobeythe state self quarantine order a financial incentive to leave. Effective March 26, Gov. David Ige ordered all visitors to self isolate for 14 days.

    Today I love sunny mornings in January. I love snow that gets packy and easy to form into snow people. I love making snow people, though it really is better as a group activity. {tag: Off White Yeezy Release Date}

    Have had to really push them to do anything. Employee, who spoke on the condition of anonymity, said some staff brought their own masks to work in March because they were concerned about COVID 19, but were allegedly told to take them off because they would scare residents. Staff members were later given flimsy dust masks from the maintenance room, said Barbeau. {tag: Adidas Yeezy Triple White Australia}

    ReplyDelete
  6. The latest trend in Coach Outlet Online is to purchase them secondhand.
    Today, buying Michael Kors Bags Outlet is looked upon as a smart choice.
    Because Michael Kors Purse Outlet are crafted of the finest material, they are known to last for many years, making them the perfect purchase.
    Some women are fanatical about changing their Coach Outlet Store Online or their style every few months, making it necessary to periodically clean out their wardrobe.
    Other women buy a MK Outlet for one specific occasion and some women just make a habit of buying a lot of purses.
    The trends are changing today; more and more people are buying classic shoes, including designer Cheap Real Yeezys.
    If your dream has always been to own a Cheap Yeezys, it is possible just by finding a store and click here.
    Coach Bags Clearance are pursued by many famous characters.
    Coach Bags Outlet in different styles and different colors are in different leathers.
    Next time, I will share some knowledge about how to maintain the bags in different material.

    ReplyDelete