You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Shekhar Bhati <sh...@gmail.com> on 2009/05/26 07:44:23 UTC

Issue regarding NativeArray assignment using Scriptable

Hi All,

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.

Thanks & Regards,
Shekhar

RE: Issue regarding NativeArray assignment using Scriptable

Posted by "John C. Turnbull" <oz...@ozemail.com.au>.
Shekhar,

 

I think you have the wrong idea about this list.  This list is for
discussing issues related to the Batik SVG toolkit.  This is not a list for
discussing general JavaScript issues.  While Batik uses Rhino, you will not
find any help here in relation to general JavaScript problems.

 

You would have more luck in the comp.lang.javascript newsgroup.

 

Hope this helps,

 

John

 

From: Shekhar Bhati [mailto:shekhar.bhati@gmail.com] 
Sent: Tuesday, 26 May 2009 15:44
To: batik-users@xmlgraphics.apache.org
Subject: Issue regarding NativeArray assignment using Scriptable

 

Hi All,

 

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.

 

Thanks & Regards,

Shekhar

 


Re: Issue regarding NativeArray assignment using Scriptable

Posted by Cameron McCormack <ca...@mcc.id.au>.
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: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org