users@woodstock.java.net

Re: Calendar component and client side events

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Fri, 09 Nov 2007 11:00:30 -0500

Rasha wrote:
> Also, it seems that the fireEvent cannot be executed on woodstock
> components...
> i.e. if I do :
> getElementById('myComponentID').fireEvent('onChange');
>

Take a look at the object type you have obtained using getElementById.
(You can also look at the rendered HTML via the View Source Chart
plug-in for Firefox.) The HTML output by the calendar component consists
of multiple tags. In this case, a table is output as the outermost HTML
element which is assigned your 'myComponentID' id. Inside this tag,
there will be HTML elements for a label, text field, and an image
hyperlink to launch the calendar popup.

If you're interested in the input element of the text field, you may
call the following functions. Note that this API is not listed in the
TLD, but is considered public.

    var calendar = getElementById('myComponentID');
    var textField = calendar.getInputElement();

If you still need an event indicating the text field has been updated,
please file an RFE. In the mean time, you may be able to subscribe to a
private Dojo event, but don't want to promote that on the alias.

Dan

> I get a javascript error.
> Is there a way I can get around this problem ?
> Thanks
> -Rasha
>
>
> Rasha wrote:
>
>> Hello,
>> I am trying to fire client side javascript when the value of the calendar
>> component changes.
>> However the provided onChange method will only fire the event if the user
>> "edits" the calendar field manually. And The onchange event does not fire
>> when the textfield value is changed programatically.
>>
>> Now an alternative would be to fire the onchange event manually when the
>> user clicks on the calendar and picks a date. But the Calendar itself does
>> not expose events, it's only its textfield that does.
>>
>> My question is, is there a way we can listen to events on the Calendar
>> itself (and not on the textfield associated with it)? i.e. is there a way
>> to set an "onClick" for example for the Calendar itself and not for its
>> textfield.
>>
>> Thanks,
>> Rasha
>>
>>
>
>