I think no need to do Brain Storming with Request Factory
for this purpose.
It can be very simple With Gwt RPC
as per my opinion .
In short the simple RPC structure as below :
GWT Code <===> InterfaceAsync <===> Interface (Synchronous)<===> Server Code
I am trying to explain with you elements it self .
The Synchronous Interface(central to the whole RPC):
import com.google.gwt.user.client.rpc.RemoteService;
public interface WidgetRPCInterface extends RemoteService
{
public Widget widgetProcessRPC(Widget myWidget);
}
The ASynchronous Interface(Key part on Client):
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface WidgetRPCInterfaceAsync
{
public void widgetProcessRPCWidget myWidget, AsyncCallback callback);
}
Here you go with the Service
(Equals to servlet) which implements "WidgetRPCInterface"
public class WidgetRPCImpl extends RemoteServiceServlet implements RPCInterface
{
private static final long serialVersionUID = 1L;
public Widget widgetProcessRPCWidget myWidget)
{
//Process your widget here (CRUD operations)
//You can change return type and return what ever you want to client .
}
**you can override doget,doPost,doDelete....etc along with your methods
}
Map the above class in your web.xml;
<servlet>
<servlet-name>widgetrpc</servlet-name>
<servlet-class>com.server.WidgetRPCImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>widgetrpc</servlet-name>
<url-pattern>/widgetrpc</url-pattern>
</servlet-mapping>
Finally in your GWT Code .Use service as below
Using in Code:
//register the service .
private final WidgetRPCInterfaceAsync widgetService =
GWT.create(WidgetRPCInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
endpoint.setServiceEntryPoint('widgetrpc');
requesting server with callback
widgetService.widgetProcessRPC(widgetFromClient, callback);
AsyncCallback callback = new AsyncCallback()
{
public void onFailure(Throwable caught)
{
//Do on fail
}
public void onSuccess(Object result)
{
//Process successfully done with result (result is which you
returned in impl class) .
}
};
P.S .Beware of package structures:
WidgetRPCInterfaceAsync ,WidgetRPCInterface should be in client* package
Widget class should be in shared* package
WidgetRPCImpl should be in server* package
And Have a look on RPC Example