I am creating a sample application for both Stock Quotes and transactions (Say Order Request and Order Response or Login Request and Login Response. The response ia asynchronous). I am using SmartGWT for the browser front end and I use JSON strings from the server to the client communication. In the client I parse the JSON string and update an array of objects. This array of objects in bound to a SmartGWT Grid.

The steps involved:

1. Send Logon Request
2. Receive Logon Response from the server asynchronously.
3. Display the logon success/failure message in a separate message window (This contains a grid with a list of messages)
4. Receive the list of stocks from the server (inturn from the database) for this user
5. Subscribe all the stocks to the server
6. Receive stock updates from the server
7. Receive static details from the server (inturn from the database) for filling up combo boxes in the order entry screen (Say list of exchanges, list of stocks... etc.,)
8. Place an order request for this client to the server
9. Receive order response from the server asynchronously.

Code Written to achieve this:

1. Send Logon Request: I am creating a Key with Username + #instancesAndSecurities (Example: ODION#instancesAndSecurities) and subscribing to the LS server. When the server sends a response back to the client it uses the same key as above. The below code is called in the Init method.

$wnd.user_name = username;
var divTag = document.createElement("div");
divTag.id = "list";
divTag.setAttribute("class","marketWatchClass");
divTag.setAttribute("source","lightstreamer");
divTag.setAttribute("table","instancesAndSecuritie sTable");
divTag.setAttribute("item",username+"#instancesAnd Securities");
divTag.setAttribute("field","instancesAndSecuritie s");
divTag.style.display = 'none';
document.body.appendChild(divTag);
$wnd.page = new $wnd.PushPage();
$wnd.page.context.setDomain("chellasoftapp.com");
$wnd.page.onEngineCreation = function(engine) {
$wnd.lsEngine = engine;
engine.connection.setLSHost("push.chellasoftapp.co m");
engine.connection.setLSPort("9090");
engine.connection.setAdapterName("BrowserToLSToTWS ");
engine.connection.setUserName(username);
engine.connection.setPassword(password);
engine.changeStatus("STREAMING");
}

$wnd.page.bind();
$wnd.page.createEngine("BrowserToLSToTWSApp", "LS", "SHARE_SESSION", true);
$wnd.pushtable = new $wnd.OverwriteTable(null, null, "MERGE");

$wnd.chellaSoft = this;
$wnd.pushtable.onItemUpdate = function (item, updateInfo) {
if ((updateInfo == null)&&(item==null)) {
return;
}
$wnd.jsonUpdatedNative(username);
}

$wnd.page.addTable($wnd.pushtable, "instancesAndSecuritiesTable");

2. Receive Logon Response from the server asynchronously: $wnd.pushtable.onItemUpdate will get called

3. Display the logon success/failure message in a separate message window (This contains a grid with a list of messages): $wnd.jsonUpdatedNative(username);method will parse the message and display in a separate window.

4. Receive the list of stocks from the server (inturn from the database) for this user: $wnd.jsonUpdatedNative(username); method will parse the list of securities and the following function is used to subscribe the list of securities

jsonEntries = "Stock1 Stock2 Stock3 Stock4 Stock5"; //This is a sample list for better understanding. The actual list will come as a paramter to this function.
$wnd.pushtable = new $wnd.NonVisualTable(jsonEntries.split(" "), new Array("instancesAndSecurities"), "MERGE");
$wnd.pushtable.onItemUpdate = function (item, updateInfo) {
if ((updateInfo == null)&&(item==null)) {
return;
}
var val = updateInfo.getNewValue("instancesAndSecurities");
$wnd.jsonUpdatedStaticJS(val);
}
$wnd.page.addTable($wnd.pushtable, "instancesAndSecuritiesTable");

5. Subscribe all the stocks to the server: Code given in point 4.

6. Receive stock updates from the server: $wnd.jsonUpdatedStaticJS(val); method will parse the JSON string and update this to an object which will inturn refresh the SmartGWT grid.

7. Receive static details from the server (inturn from the database) for filling up combo boxes in the order entry screen (Say list of exchanges, list of stocks... etc.,):

In this case I am sending the JSON string from the server using the key ODION#instancesAndSecurities. In the client side I am NOT getting this JSON string.

Can you please point of the issue in the code?