Subj : Re: array access issue - what am i doing wrong To : netscape.public.mozilla.jseng From : ash mozilla Date : Fri Jan 28 2005 06:15 pm --0-62905318-1106964902=:21302 Content-Type: text/plain; charset=us-ascii This seems to be related with inheritance. MyForm is derived from the base class and elements is a member of MyForm. If i move elements to the base class it works. how can i make rhino to treat form[0] as MyForm and not as its base class? thanks ash mozilla wrote: I'm a pretty new to Java and Rhino. I'm not sure whether I'm doing the things the right way. Here is a description: Scenario - I need to programmatically execute some javascript functions inside a web response. Approach - I'm providing my own objects for the context objects like document, window, forms etc. For this I have classes like MyDocument, MyWindow, MyForm, MyControls, etc. On getting the response I initialize these objects with their properties and event handlers. Problem - If I have a button control in the first form, the value of the control can be accessed thru window.document.forms[0].value. I load my context objects to the context by calling ScriptableObject.putProperty(....."window", window, ...); Now I want to evaluate the above control value "window.document.forms[0].elements[0].value". But evaluateString throws an exception saying something about 0.0 access. I can get window.document.forms[0], this return MyForm correctly. window.document.forms[0].elements[0] it returns as "not defined". window.document.forms[0].elements[0].value it throws the exception. what could have gone wrong? Something to do with the way I deal the arrays I think. --------------------------------- Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. --------------------------------- Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. --0-62905318-1106964902=:21302 Content-Type: text/html; charset=us-ascii
This seems to be related with inheritance. MyForm is derived from the base class and elements is a member of MyForm. If i move elements to the base class it works. how can i make rhino to treat form[0] as MyForm and not as its base class?
 
thanks

ash mozilla <ashmozilla@yahoo.com> wrote:
I'm a pretty new to Java and Rhino. I'm not sure whether I'm doing the things the right way.
Here is a description:
Scenario - I need to programmatically execute some javascript functions inside a web response.
Approach - I'm providing my own objects for the context objects like document, window, forms etc. For this I have classes like MyDocument, MyWindow, MyForm, MyControls, etc.
On getting the response I initialize these objects with their properties and event handlers.
 
Problem - If I have a button control in the first form, the value of the control can be accessed thru window.document.forms[0].value.
 
I load my context objects to the context by calling ScriptableObject.putProperty(....."window", window, ...);
 
Now I want to evaluate the above control value "window.document.forms[0].elements[0].value".
But evaluateString throws an exception saying something about 0.0 access.
I can get window.document.forms[0], this return MyForm correctly. window.document.forms[0].elements[0] it returns as "not defined". window.document.forms[0].elements[0].value it throws the exception.
 
what could have gone wrong? Something to do with the way I deal the arrays I think.
 
 


Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.


Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone. --0-62905318-1106964902=:21302-- .