For some reason if the _javascript_ is rendered in the component's onRender(MarkupStream) method (as opposed to rendering the _javascript_ through a behavior) the _javascript_ is executed correctly.

This is strange because when I look at the ajax debug window and compare the ajax responses of the two methods there isn't anything different other than rendering in a behavior causes the script to be rendered in a <header-contribution> as well as being rendered alongside the component.  I think this is caused by the issue I mention in my latest email " IBehavior#rendered() is called twice when a component that has that behavior is rendered via AJAX".

If I prevent Wicket from calling IBehavior#rendered() (as mentioned in the above referenced mail) twice on a component during an AJAX request  by commenting out the call to component.renderedBehaviors(); (AjaxRequestTarget.java line 524) then the _javascript_ is executed correctly in firefox, and that _javascript_ is not added as a <header-contribution> in the ajax response.

I don't understand why having the _javascript_ in a <header-contribution> as well as a <component> in the response would cause it not to execute correctly.

On 10/15/06, Caleb Land <[EMAIL PROTECTED] > wrote:
Okay.  I'm making this up as I go along, so this could be the worst idea ever, but what about scanning a component's response for <script> tag, putting the contents in the AjaxRequestTarget as _javascript_s, and removing the <script> tag from the normal component output?  From my reading of the source code, the evaluation of those scripts is controlled by the wicket ajax system (since a call to eval() is made when processing them).

I'm a Wicket/Web development newbie so I can't see far enough ahead to see potential problems with a solution like this.


On 10/15/06, Matej Knopp < [EMAIL PROTECTED] > wrote:
Well, I'll try to look at it later today (or tomorrow). The problem is
that firefox executes the script "automatically", while in other
browsers we need to call the scripts in the fragment manually. So I
can't affect the order in which the scripts are bing called.
I'll see what I can do about it.

-Matej

Caleb Land wrote:
> I've created the same testcase using wicket 1.2.2 and it works correctly
> in Firefox:
>
> http://www.granfalloon.com/~caleb/wicket-quickstart-1.2.2.zip
> < http://www.granfalloon.com/%7Ecaleb/wicket-quickstart-1.2.2.zip>
>
> I'm looking into the cause of it...
>
> On 10/15/06, *Caleb Land* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     I'm using the 2.0 trunk.  I think he was referring to the header
>     contribution working when added via ajax.  That does appear to work
>     (the correct <script> reference is made to the autocomplete
>     _javascript_ library), however the code that actually calls the
>     library to create the field in the browser is being called before
>     the field is placed on the page in Firefox (it works correctly in
>     the other browsers I tried).
>
>
>     On 10/15/06, *Erik van Oosten* < [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
>
>         This is the same problem I reported a few days ago for Wicket 1.2.2.
>         Igor wrote that it was already solved in th 1.x trunk. So maybe
>         this is
>         also the case for the 2.x trunk.
>
>         Regards,
>              Erik.
>
>         Caleb Land schreef:
>         >  When I add a component via ajax that contributes _javascript_ to be
>         >  executed (like the AutoCompleteTextField from
>         wicket-extensions) the
>         >  _javascript_ is executed before the component elements are added
>         to the
>         >  page in Firefox ( 1.5.0.7 <http://1.5.0.7 > <
>         http://1.5.0.7>).  The same code works
>         >  correctly in Safari, Opera, and IE7 (I haven't tests 6.x).
>         >
>         >  In the case of the AutoCompleteTextField (which adds _javascript_
>         >  through the AbstractAutoCompleteBehavior), the _javascript_:
>         >
>         >  new Wicket.Ajax.AutoComplete('<id> ', '<callbackUrl>');
>         >
>         >  gets executed before the control is added to the page, so an
>         element
>         >  with the specified id cannot be found and the autocomplete
>         >  functionality isn't added to the control.
>         >
>         >  Here is a quickstart application that demonstrates the problem:
>         >  http://www.granfalloon.com/~caleb/wicket-quickstart.zip
>         < http://www.granfalloon.com/%7Ecaleb/wicket-quickstart.zip>
>         >  < http://www.granfalloon.com/%7Ecaleb/wicket-quickstart.zip
>         <http://www.granfalloon.com/%7Ecaleb/wicket-quickstart.zip >>
>         >
>         >  if I alter AbstractAutoCompleteBehavior to execute the
>         _javascript_ in a
>         >  setTimeout() then everything work correctly in Firefox.
>         >  --
>         >  Caleb Land
>         >  ( [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>         <mailto: [EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>>)
>
>         --
>         Erik van Oosten
>         http://day-to-day-stuff.blogspot.com/
>
>
>         -------------------------------------------------------------------------
>
>         Using Tomcat but need to do more? Need to support web services,
>         security?
>         Get stuff done quickly with pre-integrated technology to make
>         your job easier
>         Download IBM WebSphere Application Server v.1.0.1 based on
>         Apache Geronimo
>         http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>         <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >
>         _______________________________________________
>         Wicket-user mailing list
>         Wicket-user@lists.sourceforge.net
>         <mailto: Wicket-user@lists.sourceforge.net>
>         https://lists.sourceforge.net/lists/listinfo/wicket-user
>         < https://lists.sourceforge.net/lists/listinfo/wicket-user>
>
>
>
>
>     --
>     Caleb Land
>     ( [EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>)
>
>
>
>
> --
> Caleb Land
> ( [EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>)
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



--
Caleb Land
( [EMAIL PROTECTED])



--
Caleb Land
([EMAIL PROTECTED])
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to