Hi, all i need to integrate gwt with lightstreamer. I have some
problems connected with how to call js in gwt. I have been using
native methods before but this time something is going wrong and i
can't understand what.

So here is every thing explained in brief:

Lightstreamer has 2 .js lib files. I include them in my host page and
they are loaded successfully.
I wrote native method that calls some js code that subscribes for ls
feeder:

        private static native void init(ListGrid grid, ListGridRecord record,
int recordIndex) /*-{
        try {
                        var page = new PushPage();
                        page.context.setDomain("localhost");
                        page.onEngineCreation = function(engine) {
                                engine.connection.setLSHost("localhost");
                        engine.connection.setLSPort(8888);
                                engine.connection.setAdapterName("HELLOWORLD");
                                engine.changeStatus("STREAMING");
                        }
                        page.bind();
                        page.createEngine("HelloWorldApp", "LS/", 
"SHARE_SESSION");

                        var schema = new Array("message","timestamp");
                        var group = new Array("greetings");

                        var nvt = new NonVisualTable(group,schema,"MERGE");
                        nvt.setSnapshotRequired(true);
                        var c = 1;
                        nvt.onItemUpdate = function(item, itemUpdate, itemName) 
{
                        if (itemUpdate.isValueChanged("message")) {
                                var msg = itemUpdate.getNewValue("message");
                                var ts = itemUpdate.getNewValue("timestamp");
                                if (c == 1)  {
                                        alert(msg + " " + ts);
                                        c+= 1;
                                }
                                record.setAttribute("message", msg);
                                record.setAttribute("timestamp", ts);
                                grid.refreshRow(recordIndex);
                        }


        }

        page.addTable(nvt,"hellotable");
        } catch(error) {
                alert(error);
        }
        }-*/;'

The same code executed in html page is working, but if i call it from
onModuleLoad()
the alert(error) shows me an error: PushPage is not defined and
PushPage is defined in the external lightstreamer js lib files, which
i included in my host page.

Here is working code in html page:

<html>

<head>
  <script src="LS/lscommons.js" type="text/javascript"></script>
  <script src="LS/lspushpage.js" type="text/javascript"></script>
</head>
<body>

<div source="lightstreamer" table="hellotable" item="greetings"
field="message">loading...</div>

<div source="lightstreamer" table="hellotable" item="greetings"
field="timestamp">loading...</div>


<div id="container">

Updates:<br/>

</div>

<script>

                                var page = new PushPage();
                        page.context.setDomain("localhost");
                        page.onEngineCreation = function(engine) {
                                engine.connection.setLSHost("localhost");
                                engine.connection.setLSPort(8888);
                                engine.connection.setAdapterName("HELLOWORLD");
                                engine.changeStatus("STREAMING");
                        }
                        page.bind();
                        page.createEngine("HelloWorldApp", "LS/", 
"SHARE_SESSION");



        var schema = new Array("message","timestamp");

        var group = new Array("greetings");



        var nvt = new NonVisualTable(group,schema,"MERGE");

        nvt.setSnapshotRequired(true);



        nvt.onItemUpdate = function(item, itemUpdate, itemName) {
                var updateText = "updating item " + itemName + ". ";



                if (itemUpdate.isValueChanged("message")) {

                        updateText += "New value for last_price: " + 
itemUpdate.getNewValue
("message");

                }



                document.getElementById("container").innerHTML += updateText + 
"<br/
>";

        }



        page.addTable(nvt,"hellotable");


</script>



</body>

</html>

In the gwt application i want to update some grid row and in the html
application i update some div as you can see.

So the main problem is why PushPage is not defined?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to