You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vinicius Carvalho <ja...@gmail.com> on 2006/08/21 20:42:13 UTC
not rendering around window.onload
Hello there! My script is not rendering it's initialization inside a
window.onload{}, any ideas what I might be doing wrong?
<body>
<![CDATA[
var requestMsgs = getRequest();
function onMessage(){
if(requestMsgs.readyState == 4){
var response = requestMsgs.responseText;
var content = document.getElementById('content');
content.innerHTML += response;
}
setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
}
]]>
</body>
<initialization>
requestMsgs.send("GET",$url,true);
requestMsgs.onReadyStateChange = onMessage;
requestMsgs.send(null);
</initialization>
The JavaScript rendered on the page:
<script type="text/javascript"><!--
var requestMsgs = getRequest();
function onMessage(){
if(requestMsgs.readyState == 4){
var response = requestMsgs.responseText;
var content = document.getElementById('content');
content.innerHTML += response;
}
setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
}
// --></script
<script language="JavaScript" type="text/javascript"><!--
requestMsgs.send("GET",$url,true);
requestMsgs.onReadyStateChange = onMessage;
requestMsgs.send(null);
// --></script>
My components inherits from BaseComponent. and has a single line of code:
<span jwcid="script">
just to render the JS
Best regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: not rendering around window.onload
Posted by Vinicius Carvalho <ja...@gmail.com>.
Thanks for the replies. Actually its not causing problems, I've solved
it by putting it around a window.onload{} and for now its ok,
following the YAGNI principle, it is working :)
I'm using Tap 4.0.2
and I need an onload, because it sets a timer for me, for eg:
function receiveMessages(){
//ajax stuff
setTimeout("receiveMessages()",2000);
}
window.onload= receiveMessages();
But once again, thank you guys for the help :P
Regards
On 8/21/06, andyhot <an...@di.uoa.gr> wrote:
> Jesse Kuhnert wrote:
> > Saying <node>.on<event>=<foo> ~will~ blow away other peoples changes.
> Of course, that's why i said it's ugly...
>
> But for non dojo, non Tap4.1 cases,
> one can easily google for the 4 lines js function that appends stuff to
> window.onload
> instead of overwriting them...
>
> But anyway, what i would like to know is what Tapestry version
> Vinicius uses and why is the <initialization> tag causing him problems?
> Why must he use window.onload?
>
> --
> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> Tapestry / Tacos developer
> Open Source / J2EE Consulting
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: not rendering around window.onload
Posted by andyhot <an...@di.uoa.gr>.
Jesse Kuhnert wrote:
> Saying <node>.on<event>=<foo> ~will~ blow away other peoples changes.
Of course, that's why i said it's ugly...
But for non dojo, non Tap4.1 cases,
one can easily google for the 4 lines js function that appends stuff to
window.onload
instead of overwriting them...
But anyway, what i would like to know is what Tapestry version
Vinicius uses and why is the <initialization> tag causing him problems?
Why must he use window.onload?
--
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: not rendering around window.onload
Posted by Jesse Kuhnert <jk...@gmail.com>.
Yes that is what would happen, but as of tapestry 4.1 we're using the built
in node.addEventHandler() function most browsers support via
dojo.event.connect()..
We can add as many window.onload blocks we like with this method without
stepping on anyone elses code.
Saying <node>.on<event>=<foo> ~will~ blow away other peoples changes.
Also, this is done for you automatically in tapestry 4.1 when using the
@Script component template semantics.
When I finally get around to upgrading dojo waiting for these load events
will be much faster than the current default window.onload semantics as the
solution discussed here has recently been implemented:
http://dean.edwards.name/weblog/2006/06/again/
On 8/21/06, Vinicius Carvalho <ja...@gmail.com> wrote:
>
> Well, yeah I though I can use this, but if Tapestry is not adding the
> window.onload now, what happens if I have 2 scripts that need to be
> loaded on the same time?
>
> does something like this work:
>
> window.onload = function(){
> firstScript contribution
> }
>
> window.onload = function(){
> secondScript contribution
> }
>
> Because, I believe that's what you get by using :
>
> <initialization>
> window.onload ...
> </initialization>
>
> on both of your scripts right?
>
> Regards
> On 8/21/06, andyhot <an...@di.uoa.gr> wrote:
> > Vinicius Carvalho wrote:
> > > Hello there! My script is not rendering it's initialization inside a
> > > window.onload{}, any ideas what I might be doing wrong?
> >
> http://tapestry.apache.org/tapestry4/UsersGuide/script.html#script.initialization
> > describes this behavior.
> > window.onload waits for all images to be loaded before getting
> triggered.
> > I think Tapestry no longer uses it. It appends that code just before
> > </body>.
> > Why is this problematic in your case?
> >
> > You're also free to set window.onload yourself however...
> > Either with the ugly
> > <initialization>
> > window.onload = function() {
> > requestMsgs.send("GET",$url,true);
> > requestMsgs.onReadyStateChange = onMessage;
> > requestMsgs.send(null);
> > }
> > </initialization>
> >
> > or with dojo.connect or similar utility functions
> >
> >
> > >
> > > <body>
> > > <![CDATA[
> > > var requestMsgs = getRequest();
> > > function onMessage(){
> > > if(requestMsgs.readyState == 4){
> > > var response = requestMsgs.responseText;
> > > var content = document.getElementById('content');
> > > content.innerHTML += response;
> > > }
> > > setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> > > }
> > > ]]>
> > > </body>
> > > <initialization>
> > > requestMsgs.send("GET",$url,true);
> > > requestMsgs.onReadyStateChange = onMessage;
> > > requestMsgs.send(null);
> > > </initialization>
> > >
> > > The JavaScript rendered on the page:
> > >
> > > <script type="text/javascript"><!--
> > >
> > >
> > >
> > > var requestMsgs = getRequest();
> > > function onMessage(){
> > > if(requestMsgs.readyState == 4){
> > > var response = requestMsgs.responseText;
> > > var content = document.getElementById('content');
> > > content.innerHTML += response;
> > > }
> > > setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> > > }
> > >
> > >
> > >
> > > // --></script
> > >
> > > <script language="JavaScript" type="text/javascript"><!--
> > >
> > > requestMsgs.send("GET",$url,true);
> > > requestMsgs.onReadyStateChange = onMessage;
> > > requestMsgs.send(null);
> > >
> > >
> > > // --></script>
> > >
> > > My components inherits from BaseComponent. and has a single line of
> code:
> > > <span jwcid="script">
> > > just to render the JS
> > >
> > > Best regards
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> > Tapestry / Tacos developer
> > Open Source / J2EE Consulting
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind.
Re: not rendering around window.onload
Posted by Vinicius Carvalho <ja...@gmail.com>.
Well, yeah I though I can use this, but if Tapestry is not adding the
window.onload now, what happens if I have 2 scripts that need to be
loaded on the same time?
does something like this work:
window.onload = function(){
firstScript contribution
}
window.onload = function(){
secondScript contribution
}
Because, I believe that's what you get by using :
<initialization>
window.onload ...
</initialization>
on both of your scripts right?
Regards
On 8/21/06, andyhot <an...@di.uoa.gr> wrote:
> Vinicius Carvalho wrote:
> > Hello there! My script is not rendering it's initialization inside a
> > window.onload{}, any ideas what I might be doing wrong?
> http://tapestry.apache.org/tapestry4/UsersGuide/script.html#script.initialization
> describes this behavior.
> window.onload waits for all images to be loaded before getting triggered.
> I think Tapestry no longer uses it. It appends that code just before
> </body>.
> Why is this problematic in your case?
>
> You're also free to set window.onload yourself however...
> Either with the ugly
> <initialization>
> window.onload = function() {
> requestMsgs.send("GET",$url,true);
> requestMsgs.onReadyStateChange = onMessage;
> requestMsgs.send(null);
> }
> </initialization>
>
> or with dojo.connect or similar utility functions
>
>
> >
> > <body>
> > <![CDATA[
> > var requestMsgs = getRequest();
> > function onMessage(){
> > if(requestMsgs.readyState == 4){
> > var response = requestMsgs.responseText;
> > var content = document.getElementById('content');
> > content.innerHTML += response;
> > }
> > setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> > }
> > ]]>
> > </body>
> > <initialization>
> > requestMsgs.send("GET",$url,true);
> > requestMsgs.onReadyStateChange = onMessage;
> > requestMsgs.send(null);
> > </initialization>
> >
> > The JavaScript rendered on the page:
> >
> > <script type="text/javascript"><!--
> >
> >
> >
> > var requestMsgs = getRequest();
> > function onMessage(){
> > if(requestMsgs.readyState == 4){
> > var response = requestMsgs.responseText;
> > var content = document.getElementById('content');
> > content.innerHTML += response;
> > }
> > setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> > }
> >
> >
> >
> > // --></script
> >
> > <script language="JavaScript" type="text/javascript"><!--
> >
> > requestMsgs.send("GET",$url,true);
> > requestMsgs.onReadyStateChange = onMessage;
> > requestMsgs.send(null);
> >
> >
> > // --></script>
> >
> > My components inherits from BaseComponent. and has a single line of code:
> > <span jwcid="script">
> > just to render the JS
> >
> > Best regards
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> Tapestry / Tacos developer
> Open Source / J2EE Consulting
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: not rendering around window.onload
Posted by andyhot <an...@di.uoa.gr>.
Vinicius Carvalho wrote:
> Hello there! My script is not rendering it's initialization inside a
> window.onload{}, any ideas what I might be doing wrong?
http://tapestry.apache.org/tapestry4/UsersGuide/script.html#script.initialization
describes this behavior.
window.onload waits for all images to be loaded before getting triggered.
I think Tapestry no longer uses it. It appends that code just before
</body>.
Why is this problematic in your case?
You're also free to set window.onload yourself however...
Either with the ugly
<initialization>
window.onload = function() {
requestMsgs.send("GET",$url,true);
requestMsgs.onReadyStateChange = onMessage;
requestMsgs.send(null);
}
</initialization>
or with dojo.connect or similar utility functions
>
> <body>
> <![CDATA[
> var requestMsgs = getRequest();
> function onMessage(){
> if(requestMsgs.readyState == 4){
> var response = requestMsgs.responseText;
> var content = document.getElementById('content');
> content.innerHTML += response;
> }
> setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> }
> ]]>
> </body>
> <initialization>
> requestMsgs.send("GET",$url,true);
> requestMsgs.onReadyStateChange = onMessage;
> requestMsgs.send(null);
> </initialization>
>
> The JavaScript rendered on the page:
>
> <script type="text/javascript"><!--
>
>
>
> var requestMsgs = getRequest();
> function onMessage(){
> if(requestMsgs.readyState == 4){
> var response = requestMsgs.responseText;
> var content = document.getElementById('content');
> content.innerHTML += response;
> }
> setTimeout('onMessage();',2000); //Refresh a cada 2 segundos
> }
>
>
>
> // --></script
>
> <script language="JavaScript" type="text/javascript"><!--
>
> requestMsgs.send("GET",$url,true);
> requestMsgs.onReadyStateChange = onMessage;
> requestMsgs.send(null);
>
>
> // --></script>
>
> My components inherits from BaseComponent. and has a single line of code:
> <span jwcid="script">
> just to render the JS
>
> Best regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org