You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rohan Kalyan <rk...@indygosoft.com> on 2008/04/23 14:43:50 UTC

Problems with Javascript in Tapestry 4.1.5

Hi all,
We moved from tapestry 4.0.2 to 4.1.5
we were using a script file and in had used the
<initialization></initialization> tag to initialize the values used in
script functions.
The variables defined in this tag were working as global variable and we
used to get the value of these variables in any script function.
After shifting to 4.1.5 the initialization is treated as a different
function and so the variables defined there are local to it, these variables
loose there values as we try to access them in different script functions.

the code is as follows
<initialization>
var thArray = new Array();
<foreach key="th" expression="ths">
        thArray[t++] = new Th("${th.thId}", ${th.position});
</foreach>
swapThArray();
</initialization>

function swapThArray() {
    var tswap = thArray.length;
    for (var k = t; k < t + (thArray.length - t - 1)/2; k++) {
        var tempth = thArray[--tswap];
        thArray[tswap] = thArray[k];
        thArray[k] = tempth;
    }
}
getting a javascript error in swapThArray that thArray has no properties


thanks in advance,

regards,
-- 
Rohan Kalyan
Indygo - www.indygo.in

Re: Problems with Javascript in Tapestry 4.1.5

Posted by Srinivas Yermal <sy...@indygosoft.com>.
In 4.0.2 the initialization code was being placed in open on the page. But
in 4.1.5 the initialization code is placed into a function and hence the
variable looses its reference. Hope that helps.
Srini.

On Wed, Apr 23, 2008 at 6:13 PM, Rohan Kalyan <rk...@indygosoft.com>
wrote:

> Hi all,
> We moved from tapestry 4.0.2 to 4.1.5
> we were using a script file and in had used the
> <initialization></initialization> tag to initialize the values used in
> script functions.
> The variables defined in this tag were working as global variable and we
> used to get the value of these variables in any script function.
> After shifting to 4.1.5 the initialization is treated as a different
> function and so the variables defined there are local to it, these
> variables
> loose there values as we try to access them in different script functions.
>
> the code is as follows
> <initialization>
> var thArray = new Array();
> <foreach key="th" expression="ths">
>        thArray[t++] = new Th("${th.thId}", ${th.position});
> </foreach>
> swapThArray();
> </initialization>
>
> function swapThArray() {
>    var tswap = thArray.length;
>    for (var k = t; k < t + (thArray.length - t - 1)/2; k++) {
>        var tempth = thArray[--tswap];
>        thArray[tswap] = thArray[k];
>        thArray[k] = tempth;
>    }
> }
> getting a javascript error in swapThArray that thArray has no properties
>
>
> thanks in advance,
>
> regards,
> --
> Rohan Kalyan
> Indygo - www.indygo.in
>



-- 
http://www.indygosoft.com

Re: Problems with Javascript in Tapestry 4.1.5

Posted by Andreas Andreou <an...@gmail.com>.
You need to do something like:

document.thArray = new Array();

On Wed, Apr 23, 2008 at 3:43 PM, Rohan Kalyan <rk...@indygosoft.com> wrote:
> Hi all,
>  We moved from tapestry 4.0.2 to 4.1.5
>  we were using a script file and in had used the
>  <initialization></initialization> tag to initialize the values used in
>  script functions.
>  The variables defined in this tag were working as global variable and we
>  used to get the value of these variables in any script function.
>  After shifting to 4.1.5 the initialization is treated as a different
>  function and so the variables defined there are local to it, these variables
>  loose there values as we try to access them in different script functions.
>
>  the code is as follows
>  <initialization>
>  var thArray = new Array();
>  <foreach key="th" expression="ths">
>         thArray[t++] = new Th("${th.thId}", ${th.position});
>  </foreach>
>  swapThArray();
>  </initialization>
>
>  function swapThArray() {
>     var tswap = thArray.length;
>     for (var k = t; k < t + (thArray.length - t - 1)/2; k++) {
>         var tempth = thArray[--tswap];
>         thArray[tswap] = thArray[k];
>         thArray[k] = tempth;
>     }
>  }
>  getting a javascript error in swapThArray that thArray has no properties
>
>
>  thanks in advance,
>
>  regards,
>  --
>  Rohan Kalyan
>  Indygo - www.indygo.in
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org