View Full Version : Fire GXT Event from within ExtJS

15 Aug 2010, 3:56 AM
I am implementing a Dashboard using the Portal and Portlet classes in GXT. The content of the Portlets are currently coded in ExtJS, and are appended to the Portlet by using the setInnerHtml() method.

The challenge I am having is that I have created an Event Listener in the GXT code, and I would like to initiate it from inside the Portlet (which is ExtJS code). I set the ID of the Portlet, but when I use Ext.getCmp(), the result is undefined.

How can I initiate a GXT event from within ExtJS code?

16 Aug 2010, 7:47 AM
Ext.getCmp will only find ExtJS components.

You need to make a bridge between yuor java code and the javascript code. You can do this with JSNI.

17 Aug 2010, 2:59 AM
Thanks! That works beautifully.

17 Aug 2010, 4:46 PM
What was you solution randymay?

18 Aug 2010, 5:18 AM
In my GXT Controller, I have the following code:

public native void nativeRefreshPortlet() /*-{
var foo = this;
$wnd.nativeRefreshPortlet = function(portletId, url) {
[email protected]::refreshPortlet(Ljava/lang/String;Ljava/lang/String;)
(portletId, url);

This creates a function in JavaScript that I can call using this code in my page:

nativeRefreshPortlet(portletId, url);