Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Widget events/calling commands - correct practice
Widget events/calling commands - correct practice [message #91005] Fri, 30 May 2008 16:04 Go to next message
Eclipse UserFriend
Originally posted by: mike.xmos.com

I'm having some timing issues with some custom widgets I've written and
wondered if there is a better way of sending events to/from them. At the
moment in order to send an event, I'm calling setX("...") in my widget
class, where the arguments are some command or event string.

Is there an actual "event" mechanism for controlling widgets, as using a
setter method doesn't really feel right - I'm not actually setting a
property but rather invoking a method in my widget like an RPC call?

Thanks,
Mike
Re: Widget events/calling commands - correct practice [message #91073 is a reply to message #91005] Sat, 31 May 2008 21:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hello Mike,

it's not quite clear for me what you mean with "sending an event to a
widget". Do you invoke a method on the client-side or on the server-side
part of your custom widget? Could you give a simple example of the code
that you want to improve?

Regards,
Ralf

Mike Wrighton wrote:
> I'm having some timing issues with some custom widgets I've written and
> wondered if there is a better way of sending events to/from them. At the
> moment in order to send an event, I'm calling setX("...") in my widget
> class, where the arguments are some command or event string.
>
> Is there an actual "event" mechanism for controlling widgets, as using a
> setter method doesn't really feel right - I'm not actually setting a
> property but rather invoking a method in my widget like an RPC call?
>
> Thanks,
> Mike
Re: Widget events/calling commands - correct practice [message #91097 is a reply to message #91073] Mon, 02 June 2008 08:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mike.xmos.com

Ralf Sternberg wrote:
> Hello Mike,
>
> it's not quite clear for me what you mean with "sending an event to a
> widget". Do you invoke a method on the client-side or on the server-side
> part of your custom widget? Could you give a simple example of the code
> that you want to improve?
>
> Regards,
> Ralf
>
> Mike Wrighton wrote:
>> I'm having some timing issues with some custom widgets I've written
>> and wondered if there is a better way of sending events to/from them.
>> At the moment in order to send an event, I'm calling setX("...") in my
>> widget class, where the arguments are some command or event string.
>>
>> Is there an actual "event" mechanism for controlling widgets, as using
>> a setter method doesn't really feel right - I'm not actually setting a
>> property but rather invoking a method in my widget like an RPC call?
>>
>> Thanks,
>> Mike

So I mean sending an event from the server to a client-side custom
widget. For example, at the moment I have a javascript editor widget
which can execute commands sent from the server. The way I've
implemented this is by having a "command" property in the widget. I then
call widget.setCommand(c) in my code. This feels like I'm setting a
property in my widget (like setAddress() in the googlemaps example) when
really I want to send an event in order to invoke some client-side code,
or possibly several events in short succession. Is this the correct way?

Mike
Re: Widget events/calling commands - correct practice [message #91138 is a reply to message #91097] Mon, 02 June 2008 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Mike,

Mike Wrighton wrote:
> So I mean sending an event from the server to a client-side custom
> widget. For example, at the moment I have a javascript editor widget
> which can execute commands sent from the server. The way I've
> implemented this is by having a "command" property in the widget. I then
> call widget.setCommand(c) in my code. This feels like I'm setting a
> property in my widget (like setAddress() in the googlemaps example) when
> really I want to send an event in order to invoke some client-side code,
> or possibly several events in short succession. Is this the correct way?

You could also implement a function "doSomething" in your client-side
custom widget (in the members section) and call it in your LCA like this:

JSWriter writer = JSWriter.getWriterFor( widget );
writer.call( "doSomething", null );

Instead of null you can also pass an Object array that holds a parameter
list. In your case, this is probably a better solution compared to using
a property.

Hope that helps, Ralf
Re: Widget events/calling commands - correct practice [message #91239 is a reply to message #91138] Mon, 02 June 2008 14:46 Go to previous message
Eclipse UserFriend
Originally posted by: mike.xmos.com

Ralf Sternberg wrote:
> Hi Mike,
>
> Mike Wrighton wrote:
>> So I mean sending an event from the server to a client-side custom
>> widget. For example, at the moment I have a javascript editor widget
>> which can execute commands sent from the server. The way I've
>> implemented this is by having a "command" property in the widget. I
>> then call widget.setCommand(c) in my code. This feels like I'm
>> setting a property in my widget (like setAddress() in the googlemaps
>> example) when really I want to send an event in order to invoke some
>> client-side code, or possibly several events in short succession. Is
>> this the correct way?
>
> You could also implement a function "doSomething" in your client-side
> custom widget (in the members section) and call it in your LCA like this:
>
> JSWriter writer = JSWriter.getWriterFor( widget );
> writer.call( "doSomething", null );
>
> Instead of null you can also pass an Object array that holds a parameter
> list. In your case, this is probably a better solution compared to using
> a property.
>
> Hope that helps, Ralf

Thanks, I'll give it a go.

Mike
Previous Topic:Best way to build a tomcat deployable WAR file.
Next Topic:M4: Preference page empty after reopening it
Goto Forum:
  


Current Time: Wed Sep 18 19:19:46 GMT 2024

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

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

Back to the top