0

has anyone ever tried to embed a gwt widget into a zul page

asked 2014-02-28 06:53:15 +0800

IanFerreira gravatar image IanFerreira
1

Hi Guys

I thought of asking this question here since I don't even get a reply from the gwt group, and frankly their documentation is pretty imature. A google on the groups just repeat whats in the docs.

Ive got this gwt widget, a casino game's slot reels spinner or sprite runner for that matter, that I need to drive from, well first from just html with javascript, prior to try and stick this into a zul.

You declare thw gwt like this in the html head

<script type="text/javascript" language="javascript" src="Slots/Slots.nocache.js"></script>

Then in the body you declare a div with a id

The hosting page html or zul will have a button that supposed to instruct this gwt thing to spin for n cycles and stop at a x frame of the hosted image sprite, well 5x3 of them actualy.

The methods is pretty simple - a "init(...)" that should be called in the page onload() a "spin( cycles", token) that should be called in the buttons onclick() and a "isDone()" spinning that I hope to drive on our ZK Timer to enable the spin button when done spinning. This is because of the lake of event being fired back into the host (well I failed to read any way to of how do external events). My code looks like this on the moment.

<body onload="onLoad()">

<div id="gwtContainer"></div>

<script type="text/javascript" language="JavaScript">

    var mySpins

    function onLoad() {
    // try 1
    alert( window.document.getElementByID( "gwtContainer" ) ) // this gives div tag
    // try 2
    alert( window.document.getElementByID( "gwtContainer" ).children[0]; // this gives undefined
    // try 3
    alert( gwtContainer.children[0]; // undefined
    // try 4
        alert( slots ); // intellij's inspector report shows a object with name "spins" - just go stale on browser

        mySpins = ??? where is this thing ???

        mySpins.doInit( "img/slots_0.png", 11, 128, 128, 1024, 4, 100, 0.5, "casino-gwt-js-slots-sprite-image" );
    }

    function doSpin() {
    mySpins.doSpin( 10, "123..." )
    }

</script>
<button id="btnSpin" name="spinButton" onclick="doSpin()">Spin</button>
</body>

The methods in the widget look like this: according to the gwt docs

///////////////////////////////////////////////////////////////////////////
// Native script accessor's

public native void doInit( final String imageUrl, final int totalFrms, final int clipW, final int clipH, final int frmpsec, final int offset, final int clipzone, final double lagfactor, final String imageStyleName ) /*-{
    this.@com.upiva.casino.gwt.slots.client.SlotsPanel::init(Ljava/lang/String;IIIIIIDLjava/lang/String;)( imageUrl, totalFrms, clipW, clipH, frmpsec, offset, clipzone, lagfactor, imageStyleName );
}-*/;

public native void doSpin( final int cycles, final String token ) /*-{
    this.@com.upiva.casino.gwt.slots.client.SlotsPanel::spin(ILjava/lang/String;)( cycles, token );
}-*/;

public native void isDone() /*-{
    this.@com.upiva.casino.gwt.slots.client.SlotsPanel::done()();
}-*/;

The docs give's alternatives of making the calls statics on the window object, but I am yet to get the object/widget/(child of the div) to call anything on it.

Currently I got it in as a source of a iframe in a zul, and it works, a internal gwt spin button does work well - so I've integrated gwt to this point.

I also yet to integrate the gwt server side rpc, thw gwt generated servlet just sits there stale in our web.xml, but that does'nt worry since I can ajax from the gwt.

I am about to can this and try to dive the widget with an ajax straight from the server on a zul button click. My only concerns is then the internet time lag, this is not properly tested zul widgets regarding the handshaking.

Help any one please ?

Regards IanF

delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-02-28 06:53:15 +0800

Seen: 14 times

Last updated: Feb 28 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More