Subj : Re: array access issue - what am i doing wrong To : ash mozilla From : Igor Bukanov Date : Tue Feb 01 2005 11:18 am See https://bugzilla.mozilla.org/show_bug.cgi?id=271401 http://groups-beta.google.com/group/netscape.public.mozilla.jseng/browse_thread/thread/679073e96a7aedd2/a658cb3c51f8b686 Regards, Igor ash mozilla wrote: > 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. .