users@woodstock.java.net

Re: dojo endTopic events

From: Ryan de Laplante <ryan_at_ijws.com>
Date: Tue, 10 Jun 2008 13:53:53 -0400

Thanks. I am certain that I have the right id:

<webuijsf:form binding="#{Page1.form1}" id="*form1*">
<webuijsf:dropDown binding="#{Page1.dropDown1}" id="*dropDown1*"
items="#{Page1.list1}" label="Proximity To Elevator" labelOnTop="true"
                            onChange="dropDown1Changed(); return false;"
style="left: 216px; top: 48px; position: absolute"
valueChangeListenerExpression="#{Page1.dropDown1_processValueChange}"/>
                       

function init() {
    var domNode = document.getElementById('*form1:dropDown1*');
    if (domNode == null || domNode.event == null) {
        return setTimeout("init();", 10);
    }
    alert('subscribing to dropDown1 endTopic');
    domNode.subscribe(domNode.event.refresh.endTopic, processEvents,
"update");
}

<webuijsf:body binding="#{Page1.body1}" id="body1" onLoad="*init();*"
style="-rave-layout: grid">
               

The alert in init() never happens. This is a new visual web project
with very little code in it. You can get it to work?


Thanks,
Ryan

Dan Labrecque wrote:
> Actually, I meant to use a "return" statement like so:
>
> function init() {
> var domNode = document.getElementById("form1:dropDown1");
> if (domNode == null || typeof domNode.subscribe !=
> "function") {
> return setTimeout('init();', 10);
> }
> domNode.subscribe(domNode.event.refresh.endTopic,
> processEvents, "update");
> }
>
> If your alerts are not being executed, it may be that you have the
> wrong id.
>
> Dan
>
> Ryan de Laplante wrote:
>> The init function was causing hundreds of "dojo.event has no
>> properties" errors. I think you intended for the subscribe to be in
>> an else block, so I changed it to look like this:
>>
>> function init() {
>> var domNode = document.getElementById('form1:dropDown1');
>> if (domNode == null || domNode.event == null) {
>> setTimeout("init();", 10);
>> } else {
>> alert('before subscribe');
>> domNode.subscribe(domNode.event.refresh.endTopic,
>> processEvents, "update");
>> alert('after subscribe');
>> }
>> }
>>
>> I never see the alerts because it seems that domNode.event always ==
>> null.
>>
>> Thanks,
>> Ryan
>>
>>
>> Dan Labrecque wrote:
>>> When are you calling the document.getElementById function? I suspect
>>> you're calling this too early and the widget has not been created,
>>> yet. In Woodstock 4.3 (next milestone), I've added an onLoad
>>> attribute to the head tag. This will ensure your function is
>>> executed after all widgets have been initialized. In the mean time,
>>> you can use the approach below.
>>>
>>> <head>
>>> <script type="text/javascript">
>>> var processEvents = {
>>> update: function(props) {
>>>
>>> document.getElementById('form1:progressBar1').setProps({"visible":false});
>>>
>>> }
>>> }
>>> function init() {
>>> var domNode = document.getElementById("form1:dropDown1");
>>> if (domNode == null || domNode.event == null) {
>>> setTimeout("init();", 10);
>>> }
>>> domNode.subscribe(domNode.event.refresh.endTopic,
>>> processEvents, "update");
>>> }
>>> </script>
>>> </head>
>>> <body onload="init();">
>>> ...
>>>
>>> Dan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
>> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>
>