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)

8 comments:

  1. 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
  2. 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