Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » custom RAP widget: how to notify SelectionListeners?
custom RAP widget: how to notify SelectionListeners? [message #129949] Thu, 23 April 2009 20:07 Go to next message
David Donohue is currently offline David DonohueFriend
Messages: 104
Registered: July 2009
Senior Member
Hi, I have had some success getting some Google Visualization charts to
render as RAP widgets.
http://code.google.com/apis/visualization/documentation/gall ery.html

I am having difficulty figuring out how to best make my custom widgets
notify listeners of events. E.g. I would like to notify selection events
on the Google Visualization Table widget
http://code.google.com/apis/visualization/documentation/gall ery/table.html

I suppose I would like to be able to add SelectionListener to my Table
custom widget. Thanks for any direction!
Best,
David Donohue
Re: custom RAP widget: how to notify SelectionListeners? [message #129962 is a reply to message #129949] Fri, 24 April 2009 06:46 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi David,

when you want to fire the selection event, use this code to add the
event in the request and to send it:
----
var req = org.eclipse.swt.Request.getInstance();
var id = widgetManager.findIdByWidget( this );
req.addEvent( "org.eclipse.swt.events.widgetSelected", id );
req.send();
----
From your CustomWidgetLCA#readData just call
----
ControlLCAUtil.processSelection( widget, null, true );
----
This will fire the selection event on your custom widget.

Best,
Ivan

David Donohue wrote:
> Hi, I have had some success getting some Google Visualization charts
> to render as RAP widgets.
> http://code.google.com/apis/visualization/documentation/gall ery.html
>
> I am having difficulty figuring out how to best make my custom widgets
> notify listeners of events. E.g. I would like to notify selection
> events on the Google Visualization Table widget
> http://code.google.com/apis/visualization/documentation/gall ery/table.html
>
>
> I suppose I would like to be able to add SelectionListener to my Table
> custom widget. Thanks for any direction!
> Best,
> David Donohue
>
Re: custom RAP widget: how to notify SelectionListeners? [message #130305 is a reply to message #129962] Mon, 27 April 2009 03:51 Go to previous messageGo to next message
David Donohue is currently offline David DonohueFriend
Messages: 104
Registered: July 2009
Senior Member
Hi Ivan,
Your suggestion is much appreciated! I tried the approach you suggested
but it is not working.

I confirmed that my widget's JS file is capturing the selection event (by
alerting upon each selection. However the events do not seem to make it
to TableLCA#readData(), as logging here shows nothing happens after the
selection is made and the alert() shows a message.

Thanks if you get any ideas!

Some snippets:

TableLCA.java:
public void readData( final Widget widget ) {
Table table = ( Table )widget;
String selectedItem = WidgetLCAUtil.readPropertyValue( table,
"selectedItem" );
table.setSelectedItem( selectedItem );
log.info( "TableLCA.readData(): selectedItem=" + selectedItem);
ControlLCAUtil.processSelection( table, null, true );
}


Table.js:
google.visualization.events.addListener(chart, 'select',
function() {
var row = chart.getSelection()[0].row;
//this alerts appropriately upon selection:
alert('You selected ' + dataTable.getValue(row, 0));
this.setSelectedItem(dataTable.getValue(row, 0));

//fire selection event
var req = org.eclipse.swt.Request.getInstance();
var id = widgetManager.findIdByWidget( this );
req.addEvent( "org.eclipse.swt.events.widgetSelected", id );
req.send();
});

David Donohue
Re: custom RAP widget: how to notify SelectionListeners? [message #130369 is a reply to message #130305] Mon, 27 April 2009 07:59 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi David,

if the TableLCA#readData is not called at all after the request being
sent from the JS, the problem is somewhere else. After the request from
the client is sent, the Lifecycle is executed on the server. The
readData is part of this life cycle. Did you check for JS errors? With
Firebug for example.

Best,
Ivan

David Donohue wrote:
> Hi Ivan,
> Your suggestion is much appreciated! I tried the approach you
> suggested but it is not working.
> I confirmed that my widget's JS file is capturing the selection event
> (by alerting upon each selection. However the events do not seem to
> make it to TableLCA#readData(), as logging here shows nothing happens
> after the selection is made and the alert() shows a message.
>
> Thanks if you get any ideas!
>
> Some snippets:
>
> TableLCA.java:
> public void readData( final Widget widget ) {
> Table table = ( Table )widget;
> String selectedItem = WidgetLCAUtil.readPropertyValue( table,
> "selectedItem" );
> table.setSelectedItem( selectedItem );
> log.info( "TableLCA.readData(): selectedItem=" + selectedItem);
> ControlLCAUtil.processSelection( table, null, true );
> }
>
>
> Table.js:
> google.visualization.events.addListener(chart, 'select',
> function() {
> var row = chart.getSelection()[0].row;
> //this alerts appropriately upon selection:
> alert('You selected ' + dataTable.getValue(row, 0));
> this.setSelectedItem(dataTable.getValue(row, 0));
>
> //fire selection event
> var req = org.eclipse.swt.Request.getInstance();
> var id = widgetManager.findIdByWidget( this );
> req.addEvent( "org.eclipse.swt.events.widgetSelected",
> id );
> req.send();
> });
>
> David Donohue
>
Previous Topic:starting/using RAP Theme Editor
Next Topic:Implementing a RAP monitor
Goto Forum:
  


Current Time: Sun Nov 28 15:56:55 GMT 2021

Powered by FUDForum. Page generated in 0.01802 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top