:: Forum >>

HOW-TO: Get a server XML message into a table and process it

I have a grid with some data and want to execute some transactions at the server when the user modifies some of the columns of the grid. I have a working solution rather simple. Here it is:

oGrid.onCellValidated = function(text,col,row) {
var r = new AW.HTTP.Request;
r.setURL("transactions.php");
r.setRequestMethod("POST");
r.setParameter("text",text);
r.setParameter("col",col);
r.setParameter("row",row);
r.setParameter("field",myColumns[col]);
r.request();
r.response = function(data) {
oGridLabel.setControlText(data);
}
}

The program "transactions.php" uses the "field" parameter as an indicator of which field the user has changed, updates it with the new value ("text") and send come confirmation message. So what I get is just a message confirming the success or fail of the transaction.

Now I want to go ahead and send from the PHP program a XML response with some structure, for example a return code and a message. Something like this:

<retcode>00</retcode>
<message>Transaction OK</message>

So my question is what is way to process this XML response? I suppose that the way is to import the data into a table structure and then access the data and process it.

I have read the forums and the quickref but only see examples of the table structure to fill the grid, which is not what I want. I only want to process a structured message from the server.

I have started modifying my code, but don't see any good example about how to fill tha table and to query the table.

oGrid.onCellValidated = function(text,col,row) {
var r = new AW.HTTP.Request;
var table = new AW.XML.Table;
var defaultResponse = table.response;
r.setURL("updateSingleCellXML.php");
r.setRequestMethod("POST");
r.setParameter("text",text);
r.setParameter("col",col);
r.setParameter("row",row);
r.setParameter("field",myColumns[col]);
r.request();
var columnNodes("retcode","message");
r.response = function(xml) {
// call the default method
defaultResponse.call
table.setRows("//NewDataSet/*");
table.setColumns(columnNodes);
table.response(text);
// To Do:
//extract the retcode from XML response
//extract the message from XML response
//oGridLabel.setControlText(XMLmessage);
}
}

Anyone can point me to a good example or something in the documentation that explains how to proceed?

Thanks so much.

Martin Duran
Sunday, March 26, 2006

This topic is archived.


Back to support forum

Forum search