Shekhar Bhati:
> I have a serious problem using Rhino script.
> I have a hidden input variable in my jsp and my task is to assign a array to
> this object in a javascript file.
> myform.myObject.value=myArray;
>
> In my put(){} method I have written this code :
>
> window.eval(name.toString() + '=' + value.toString());
>
> It works for all other assignments other than this array one and gives this
> array
> *netscape.javascript.JSException: Failure to evaluate
> value=NativeArray;@53537c*
> Anyone have any idea how can I do this task.
As John says, this seems like a Rhino question more than a Batik
question. However I can see from your output what the problem is: the
toString() of your NativeArray object doesn’t return a string that is
suitable for parsing again as script. You’ll need to get something that
looks like "[1, 2, 3]". Rhino implements a toSource() JavaScript method
on Array objects that will give you that. Try this (untested):
String jsSourceOfTheArray =
ScriptableObject.callMethod(ctx, value, "toSource", null);
where ctx is your org.mozilla.javascript.Context object.
--
Cameron McCormack ≝ http://mcc.id.au/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]