Donnerstag, 29. Januar 2009

GWT-Ext: How to use the Connection-Method POST

Sometimes you need to transfer more Data from GWT-Ext to your Server. In this case you need the HTTP-Method POST. You have to do the following steps.

// first we need a ConnectionConfig-object
ConnectionConfig conConf = new ConnectionConfig();

// We should set now the request-URL and method
conConf.setUrl("index.php");
conConf.setMethod(Connection.POST);

// Now we can start building the parameter array for the data which should be sended to the server:
UrlParam[] params = new UrlParam[1];
params[0] = new UrlParam("request", 505);

// Set the parameters to the config object
conConf.setExtraParams(params);

// In the next step we can create a new Connection object...
Connection dataCon = new Connection(conConf);

// ... and use it e.g. for a HttpProxy object
dataProxy = new HttpProxy(dataCon);