users@woodstock.java.net

Re: dojo endTopic events

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Fri, 06 Jun 2008 19:21:01 -0400

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

Ryan de Laplante wrote:
> Hi,
>
> When a dropdown is changed I make a busy indicator component visible
> and call the value change listener on the server. I want to listen
> for the refresh.endTopic event so that I can hide the busy indicator
> when the request is completed.
> I've read the TLD example and an other woodstock AJAX example which
> helped me come up with this:
>
> var processEvents = {
> update: function(props) {
>
> document.getElementById('form1:progressBar1').setProps({"visible":false});
>
> }
> }
>
> // Subscribe to refresh event.
> var domNode = document.getElementById("form1:dropDown1");
> domNode.subscribe(domNode.event.refresh.endTopic, processEvents,
> "update");
>
> I put that code in the method that is called by dropDown1's onChange.
> I've also tried it outside of any function. The error I get is:
> "domNode.subscribe is not a function".
>
> I've also tried it like this (also from woodstock docs):
>
> dojo.event.topic.subscribe(webui.suntheme.widget.dropDown.event.refresh.endTopic,
> processEvents, "update");
>
> and the error I get is: "dojo.event has no properties". Please
> forgive me if this is a dumb question, but I am new to doing
> JavaScript stuff and AJAX. I'll be reading a book on JavaScript soon.
>
>
> Thanks,
> Ryan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>