cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Johnston" <coc...@lojjic.net>
Subject Re: Weird Javascript error in continuations
Date Tue, 25 Jul 2006 15:00:19 GMT
> I just came across a very strange error, possibly a bug in Cocoon!
>
> It's easy to reproduce: edit samples/blocks/forms/flow/registration.js
> from Cocoon 2.1.8, adding the lines marked with '>'
>
>
> function registration() {
>>   var useless = 'one two';
>     var form = new Form("forms/registration.xml");
>
>     // The showForm function will keep redisplaying the form until
>     // everything is valid
>     form.showForm("registration-display-pipeline");
>
>>   useless = useless.split(' ');
>     var model = form.getModel();
>     var bizdata = { "username" : model.name }
>     cocoon.sendPage("registration-success-pipeline.jx", bizdata);
> }
>
>
> Then do the following:
>
> 1. invoke /samples/blocks/forms/registration
>     -> the form is created and displayed, OK
>
> 2. submit the form with valid fields (thus calling continuation #1)
>     -> "Registration successful", OK
>
> 3. either hit reload or go back and re-submit it
>    (thus calling the SAME continuation again)
>     -> "org.mozilla.javascript.EcmaError: split is not a function."


This is working correctly.

First you assign the 'useless' variable a String value, then you create
the continuation.  When you resume the continuation the first time, you
re-assign the 'useless' variable so that it now holds an Array value
(String.split() returns an Array).  When you resume the continuation
again, you try to call .split() on the 'useless' var, which is now an
Array, and the error is appropriately thrown since an Array has no such
method.





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


Mime
View raw message