Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Mar 2012
    Location
    Frankfurt am Main
    Posts
    7

    getting field value directly via javascript

    Hi,

    my Java Adapter has a following piece of code:

    Code:
    final Map<String, String> sentimentIndexMap = new HashMap<String, String>();
    sentimentIndexMap.put("INDEX", Double.toString(sentimentIndex));
    listener.update("SENTIMENT", sentimentIndexMap, false);
    Now, when I try to get the SENTIMENT INDEX property in javascript using any of the following lines I get nothing:

    Code:
    var si = updateInfo.getNewValue("INDEX");
    var si = updateInfo.getNewValue("SENTIMENT.INDEX");
    var si = updateInfo.getNewValue("SENTIMENT");
    So, the question is: how do I extract that value? and why does the same works for other parameters ("BID"):
    Code:
    var pushtable = new OverwriteTable(null, null, "MERGE");
    pushtable.onItemUpdate = updateItem;
    pushtable.onChangingValues = formatValues;
    pushtable.setPushedHtmlEnabled(true);
    page.addTable(pushtable, "quotestable");
    function updateItem(item, updateInfo) {
            if (updateInfo == null) {
                    return;
     	}
    	if (updateInfo.getNewValue("BID") == null) {
    	        return;
    	}
    	var oldLast = updateInfo.getOldValue("BID");
    	if (oldLast == null) {
    	        updateInfo.addField("#trend_color",greenColor,true);
    	} else if (updateInfo.isValueChanged("BID")) {
    	        if (oldLast > updateInfo.getNewValue("BID")) {
    	                updateInfo.addField("#trend_color",redColor,true);
    	        } else {
    	                updateInfo.addField("#trend_color",greenColor,true);
    	        }
    	}
    	if (item != null && item >= 0 && item <= quotesarr.length) {
    	        var currentTime = new Date();
    	        var hours = currentTime.getHours();
    	        var minutes = currentTime.getMinutes();
    	        if (minutes < 10){
    	                minutes = "0" + minutes;
    	        }
    	        var timetextfield = document.getElementById(quotesarr[item-1]+'.TIME').innerHTML = hours + ":" + minutes;
    	}
    	var si = updateInfo.getNewValue("INDEX");
    	if (si != null) {
    	        var blatextfield = document.getElementById('bla').innerHTML = si;
    	} else {
    	        var blatextfield = document.getElementById('bla').innerHTML = "bla";
    	}
    }
    function formatValues(item, itemUpdate) {
    	if (itemUpdate == null) {
    	        return;
    	}
    	itemUpdate.setHotTime(fadeout);
    	var backH = itemUpdate.getServerValue("#trend_color");
    	itemUpdate.setAttribute("BID",backH, null,"backgroundColor");
    	itemUpdate.setAttribute("ASK",backH, null,"backgroundColor");
    }

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,093
    You should ensure that the "INDEX" field is part of the subscription schema.
    This cannot be determined by the provided code snippet, as the
    new OverwriteTable(null, null, "MERGE");
    form (with no schema specified) implies that the Html Client Library finds the fields by looking for your Html cells in the page.

    You can easily check which fields are subscribed to by looking at the Server log.
    You can find them embedded in the "/lightstreamer/control" request, logged with the factory log configuration;
    alternatively, you can have a more detailed log by setting the "LightstreamerLogger.subscriptions" logger at DEBUG level.

 

 

Similar Threads

  1. on field missing error on javascript execution
    By betasec in forum Client SDKs
    Replies: 1
    Last Post: June 8th, 2012, 08:52 AM
  2. Item vs Field
    By nickponico in forum General
    Replies: 1
    Last Post: March 1st, 2010, 09:38 AM
  3. Replies: 1
    Last Post: November 2nd, 2009, 04:55 PM
  4. SDK for JavaScript?
    By rufnex in forum General
    Replies: 1
    Last Post: September 17th, 2007, 09:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 12:56 AM.
Lightstreamer Logo