Widget events/calling commands - correct practice [message #91005] |
Fri, 30 May 2008 12:04  |
Eclipse User |
|
|
|
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 #91239 is a reply to message #91138] |
Mon, 02 June 2008 10:46  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03986 seconds