Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Smart gwt + light streamer = integration problems

    Hi, all. I need to integrate light streamer with smart gwt. I tried to show existing static page in gwt with
    Code:
    // this page is hosted in the light streamer server
    htmlPane.setContentsURL("http://localhost:8888/demos/HelloWorld/");
    and it worked, but i don't think this is the best approach.

    I need to integrate the following code in smart gwt :
    Code:
    <html>
    
    
    
    <head>
    
    	<title>Hello World with Lightstreamer</title>
    
    	<script language="JavaScript" src="LS/lscommons.js"></script>
    
    	<script language="JavaScript" src="LS/lspushpage.js"></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>
    
    
    
    <script>
    
    	var page = new PushPage();
    
    	page.onEngineCreation = function(engine) {
    
    		engine.connection.setAdapterName("HELLOWORLD");
    
    		engine.changeStatus("STREAMING");
    
    	}
    
    	page.bind();
    
    	page.createEngine("HelloWorldApp", "LS", "SHARE_SESSION");
    
    
    
    	var pushtable = new OverwriteTable(null, null, "MERGE");
    
    	page.addTable(pushtable, "hellotable");
    
    </script>
    
    
    
    </body>
    
    </html>
    This is the static page, that light streamer updates and i just set it in htmlPane.

    In my first approach i just display the page, but i can't acess the data that is updated.

    I tried to use htmlPane.getChilderen() but no success. Coulde some one tell me how to translate the above page in smart gwt code, so i can access the "message" and "timestamp" values that come from light streamer.

    Regards.

    #2
    the htmlPane.getChildren only works for SmartClient child objects.

    If you simply want to access the html code generated, you can use the static methods of the DOM class:

    DOM.getElementById(htmlTagID);

    http://google-web-toolkit.googlecode...w-summary.html

    Comment


      #3
      Originally posted by farmer
      the htmlPane.getChildren only works for SmartClient child objects.

      If you simply want to access the html code generated, you can use the static methods of the DOM class:

      DOM.getElementById(htmlTagID);

      http://google-web-toolkit.googlecode...w-summary.html
      OK, but in that case i must embed the html in the html pange, not load it from external page?

      Comment


        #4
        How to get the children of HtmlFlow?
        It seems that HtmlFlow is iframe that wraps the page passed with content url.
        But flow.getDOM().getChildNodes() returns me empty list. How could i access some div within this iframe using flow.getDOM() ?

        Comment


          #5
          Why do this? SmartGwt has a Messaging Module that's already integrated and less expensive than separate products.

          There is a user around (senordhuff) who succesfully integrated LightStreamer and SmartClient, however last we heard he wished he had not bothered :)

          Comment


            #6
            Well, that's our client's decision. They already have light streamer license for other products and want to use it in our product again. I managed to load html page from light streamer in gwt(using HtmlFlow) but it push the html page in iframe and i do not know how to access the page using dom. HtmlFlow has method getDOM().getOwnerDocument() ... but i miss something! :(\

            Thanks for the info i will look for this guy :)

            Originally posted by Isomorphic
            Why do this? SmartGwt has a Messaging Module that's already integrated and less expensive than separate products.

            There is a user around (senordhuff) who succesfully integrated LightStreamer and SmartClient, however last we heard he wished he had not bothered :)

            Comment


              #7
              Hi, all.

              I successfully integrated lightstreamer with (smart) gwt. It is just one native js method. Here is a simple example of usage:

              Code:
              package ls.client;
              
              import com.google.gwt.core.client.EntryPoint;
              import com.google.gwt.core.client.JavaScriptObject;
              import com.google.gwt.user.client.ui.RootPanel;
              import com.smartgwt.client.util.SC;
              import com.smartgwt.client.widgets.Button;
              import com.smartgwt.client.widgets.events.ClickEvent;
              import com.smartgwt.client.widgets.events.ClickHandler;
              import com.smartgwt.client.widgets.grid.ListGrid;
              import com.smartgwt.client.widgets.grid.ListGridField;
              import com.smartgwt.client.widgets.grid.ListGridRecord;
              import com.smartgwt.client.widgets.layout.VLayout;
              
              public class GwtLSIntegrationTest implements EntryPoint {
              
              	public void onModuleLoad() {
              		
              		final VLayout main = new VLayout();
              		main.setHeight(600);
              		main.setWidth(1000);
              		
              		
              		final ListGrid grid = new ListGrid();
              		grid.setAutoFetchData(true);
              		grid.setHeight100();
              		grid.setWidth100();
              		final ListGridField field1 = new ListGridField("message", "message");
              		final ListGridField field2 = new ListGridField("timestamp", "timestamp");
              		grid.setFields(field1, field2);
              		main.addMember(grid);
              		// init
              		final ListGridRecord record = new ListGridRecord();
              		record.setAttribute("message", "loading...");
              		record.setAttribute("timestamp", "");
              		grid.addData(record);
              		final int index = grid.getRecordIndex(record);
              		RootPanel.get("nameFieldContainer").add(main);
              		final Button button = new Button("Start");
              		init(grid, record.getJsObj(), index);
              		button.addClickHandler(new ClickHandler() {
              			@Override
              			public void onClick(ClickEvent event) {
              				SC.say(grid.getSelectedRecord().getAttributeAsString("message") + " " + grid.getSelectedRecord().getAttributeAsString("timestamp"));
              			}
              		});
              		main.addMember(button);
              		main.draw();
              	}
              	
              	private static native void init(ListGrid grid, JavaScriptObject record, int index) /*-{
              	try {
              			var page = new $wnd.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 $wnd.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");
              				record["message"] = msg;
              				record["timestamp"] = ts;
              				var self = grid.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                          	self.refreshRow(index);
              			}
              	}
              	
              	page.addTable(nvt,"hellotable");
              	} catch(error) {
              		alert(error);
              	}
              	}-*/;
              	
              }
              The tricky part (for non javascript dev or for me) was $wnd in front of the PushPage and NonVisialTable. If you don't have $wnd you will get PushPage is not defined.

              The next tricky thing is the same origin policy. I just added this in my gwt.xml file:
              Code:
              <inherits name="com.google.gwt.core.Core"/>
              	<add-linker name="xs" />
              And at last you must include the 2 ligthstreamer js lib files as external js libs. You may do it in your host page or in the gwt.xml like this:
              Code:
              <script src="LS/lscommons.js"></script>
              <script src="LS/lspushpage.js"></script>
              I will create some generic widget that wraps this native code.
              Hope this helps someone. :)
              Regards.

              Comment

              Working...
              X