Passing Clicks to Exported Widget

11 views
Skip to first unread message

V S

unread,
Apr 18, 2014, 9:32:21 PM4/18/14
to gwtex...@googlegroups.com
I have a simple GWT widget with a button in it.
Exporting it works good, widget is created and inserted into the table but button does not react to clicks any more.
Any ideas?


Here what I do in the page java script:


<script type="text/javascript">
.....

var cWidget = new js.test.JsCustomWidget();

var row = document.getElementById("WidgetRow");
row.appendChild(cWidget.getElement());

.....
 </script>
.......

    <table align="center">
      <tr>
        <td style="font-weight:bold;" id="WidgetRow"></td>        
      </tr>
     </table>

................
Message has been deleted
Message has been deleted

V S

unread,
Apr 22, 2014, 1:45:58 PM4/22/14
to gwtex...@googlegroups.com
Not sure if this Group is still active, 
but I'll use "self-checkout" option :)

Solution: do not use appendChild(cWidget.getElement()) in JavaScript, it inserts widget's element in the DOM, but does not correctly hook all the interactions.

Instead pass ID of the supposed parent to exported Widget and use "add" method in Java:

public JsCustomWidget(String containerId) {
     super();

     Panel panel = RootPanel.get(containerId);
     if (panel != null)
     panel.add(this);
}

Manuel Carrasco Moñino

unread,
Apr 23, 2014, 1:26:08 AM4/23/14
to gwtex...@googlegroups.com
Yes it is active.

You cannot manipulate the dom directly, otherwise you are breaking widget hierarchy and GWT event mechanism.


--
Has recibido este mensaje porque estás suscrito al grupo "gwtexporter" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a gwtexporter...@googlegroups.com.
Para acceder a más opciones, visita https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages