On Mon, Feb 25, 2013 at 5:52 PM, Martin Dietze <d...@fh-wedel.de> wrote:

> On Mon, February 25, 2013, Martin Grigorov wrote:
>
> > > | AjaxCallListener myAjaxCallListener = new AjaxCallListener();
> > > | myAjaxCallListener.onBeforeSend( return "for ( instance in
> > > CKEDITOR.instances ) CKEDITOR.instances[instance].updateElement();" );
> > >
> >
> > except the leading "return" all looks OK to me.
> > Add some logging with console.log() and see what is available in the
> > context.
>
> OK, I got it, thought this would be nice to have in the archives
> for others. First, the "return" was of course not from the real
> code, I did some on-the-fly optimizing of the code to avoid
> unnecessary complexity in this example before I posted it.
>
> The culprit was basically the lack of three letters - "var".
> The variable "instance" was not declared before use. While this
> is totally fine when executed in the browser, it throws an
> exception in the code environment in which Wicket calls this
> callback. This way the code works:
>
> | var instance; for ( instance in CKEDITOR.instances )
> CKEDITOR.instances[instance].updateElement();
>
> I had to ask my local JS guru for help, I would never have found
> this one alone.
>
>
> As I've run across a number of issues migrating from 1.4 to 6.6
> now, I would like to suggest creating and continuously extending
> a Wiki page, like: "Old patterns vs. New patterns", where we can
> just add such things (as: for Ajax, instead of
> JavaScriptUtils.writeJavaScript() inside onRender() use
> OnDomReadyHeaderItem.forScript() in renderHead()), so that they
> can be found more easily?
>

Well, I have written a Wiki page and few blog articles about the changes in
Wicket 6 but it seems you haven't read them before asking :-)

In my opinion no one should use Component#onRender(). You should really
understand how Wicket rendering internals work (MarkupStream,
MarkupElement, component resolvers, etc.) to override it. There are hooks
in Behavior class for almost everything a user code should ever need -
beforeRender, afterRender, renderHead.


>
> Cheers,
>
> M'bert
>
> --
> ----------- / http://herbert.the-little-red-haired-girl.org /
> -------------
> =+=
> Tower: Hoehe und Position?
> Pilot: Ich bin 1.80m und sitze vorne links.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to