On 3/9/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:


Hmmm, yeah, that's interesting. Maybe others thought of this before,
but I hadn't. So we can add header (/body?) contributions via ajax
dynamically now. What we want here is the opposite: remove them when
the linked component was removed/ replaced, right?

Eelco




Right, my first instinct was to ask for an onRemove as part of the
component/behavior lifecycle. But with larger issues looming for wicket, I
decided to hold off. Turns out my problem with the AjaxTimer was pretty
straight forward to solve since wicket generates unique ids for all
components even if they occupy the same place in the hierarchy.

In case anyone is interested, you just need to override getCallbackScript :

@Override
           protected CharSequence getCallbackScript(boolean
recordPageVersion)
           {
               String mId = getComponent().getMarkupId();
               StringBuilder sb = new StringBuilder("exec_func(function() {
");
               sb.append("var el = wicketGet('" + mId + "'); ");
               sb.append("if(null != el) {");
               sb.append(super.getCallbackScript(recordPageVersion));
               sb.append("}");
               sb.append("})");

               return sb.toString();
           }


This just wraps it in an anonymous func that checks to see if the dom
element is still there before calling the timer. exec_func is necessary
because the anonymous function is passed to setTimeout as string and ff is
not happy with that (it does only what it says). But it is a hack and I
would love to have a wicket way of doing this.

Thanks for getting back to me.

best,

jim
-------------------------------------------------------------------------
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