Hi Stefan,

without asking for Igor's permission, I'll just append the code I think
you are talking about.
I don't have access to the tracker either, but I downloaded the code
earlier.
Igor had some reasons why he didn't commit that code, but you can easily
include it to your project.

The obvious usage is to subclass the AjaxPoller and add it to the
Component you wanna have updated.
Works fine for me. (Thank you Igor)

Martin

import wicket.Response;
import wicket.ajax.AbstractDefaultAjaxBehavior;
import wicket.ajax.AjaxRequestTarget;
import wicket.util.time.Duration;

    /**
     * Implementation of an ajax poller
     *
     * @author ivaynberg
     */
    public abstract class AjaxPoller extends AbstractDefaultAjaxBehavior {
        private Duration duration;

        /**
         * Constructor
         *
         * @param interval
         *            polling interval
         */
        public AjaxPoller(Duration interval) {
            this.duration = interval;
        }

        /**
         *
         * @see wicket.ajax.AbstractDefaultAjaxBehavior#getCallbackScript()
         */
        @Override
        public final CharSequence getCallbackScript() {
            return "setTimeout(function() { " + getCallbackScript(false,
true) + " }, " + duration.getMilliseconds()
                    + ");";
        }

        /**
         *
         * @see
wicket.behavior.AbstractAjaxBehavior#onRenderHeadContribution(wicket.Response)
         */
        @Override
        protected void onRenderHeadContribution(Response response) {
            if (!isComplete()) {
                response.write("<script>");
                response.write(getCallbackScript().toString());
                response.write("</script>");
            }
        }

        /**
         *
         * @see
wicket.ajax.AbstractDefaultAjaxBehavior#respond(wicket.ajax.AjaxRequestTarget)
         */
        @Override
        protected final void respond(AjaxRequestTarget target) {
            if (!isComplete()) {
                target.appendJavascript(getCallbackScript().toString());
            } else {
                onComplete(target);
            }
        }

        /**
         * Callback when the process being polled is completed
         *
         * @param target
         */
        protected abstract void onComplete(AjaxRequestTarget target);

        /**
         * Returns true if the process being polled for is completed, false
         * otherwise
         *
         * @return true or false
         */
        protected abstract boolean isComplete();
    }


Stefan Lindner schrieb:
> Dear Martijn,
>
> sorry for asking again. Woogle is fine, but
> http://woogle.billen.dk/search/q/AjaxSelfUpdatingTimerBehavior%20stoppin
> g
> points to a method named isComplete and a developer issue
> https://sourceforge.net/tracker/?func=detail&atid=684978&aid=1539101&gro
> up_id=119783
> The only classes in wicket that have a isComplete methods are in
> wicket.extensions...wizzard and do not seem to be that right thing.
> I can't open the
> https://sourceforge.net/tracker/?func=detail&atid=684978&aid=1539101&gro
> up_id=119783
> I found another hint under
> http://www.mail-archive.com/[email protected]/msg19068.h
> tml but I cant' find the cited ajax poller anywhere in wicket.
>
> Sorry once again for my dumb question, maybe it is because my English is
> not good enough to understand the thread in woogle but can you tell me a
> little bit more how to stop an AjaxSelfUpdatingTimerBehavior?
>
> Stefan Lindner
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to