Widget events/calling commands - correct practice [message #91005] |
Fri, 30 May 2008 16: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 #91073 is a reply to message #91005] |
Sat, 31 May 2008 21:11 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
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.03632 seconds