TypeError: Cannot find default value for object. (<cmd>#1)
I get it with this code:-
code = "event.value = util.printd("mmmm d, yyyy", new Date());";
Object testjs_event = org.mozilla.javascript.Context.javaToJS( testjs,
scope );
org.mozilla.javascript.ScriptableObject.putProperty( scope,
"event", testjs_event );
Object testjs_util = org.mozilla.javascript.Context.javaToJS( testjs,
scope );
org.mozilla.javascript.ScriptableObject.putProperty( scope,
"util", testjs_util );
Object result = cx.evaluateString(scope, code, "<cmd>", 1, null);
The testjs is an object of class with these javascript methods in:-
private int value = -1;
public void jsConstructor(int inVal)
public int jsGet_value()
public void jsSet_setValue(int inVal)
Can anyone shed any light on this situation please?
Kind Regards all
Chris wade
There are two possible causes both related to type conversion.
1) Does util.printd have signature (String, NativeDate)? If not, JS
might be trying to coerce the here.
2) Assignment to event.value. What is the signature of event.setValue(
XX )?
You can try inserting a \n char in the code string to see if the
TypeError changes lines:
Code = "event.value = \n util.printd("mmmm d, yyyy", new Date());"
Kevin
Kind Regards all
Chris wade
_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
All java classes attached.
Please Help.
Chris
this is my output:-
JpedalDefaultJavascript constructed
localised=TypeError: Cannot find default value for object. (test#1)
message=TypeError: Cannot find default value for object. (test#1)
Error=function Error() { [native code for Error.Error, arity=1] }
exiting -
Ive managed to get rid of that problem, but you know earlier you said
NativeDate,
where is this class defined? as i cant find it and my compiler wont
allow it.
I got round the earlier problem by adding
org.mozilla.javascript.ScriptableObject.defineClass(scope,
DefaultJavascript.class);
Regards
Chris wade
Ruland Kevin-BHP637 wrote:
> Chris,
>
> I suspect the problem is with jsGet_printd, jsSet_printd. This
> convinces JS that "printd" is a property with setters and getters.
> Instead you should replace the two of them with jsFunction_printd which
> defines "printd" as a method.
>
> Kevin
>
> -----Original Message-----
> From: chris wade orange [mailto:chri...@motogpwade.freeserve.co.uk]
> Sent: Tuesday, June 10, 2008 11:13 AM
> To: Ruland Kevin-BHP637
> Subject: Re: HELP adding javascript to a java applications
>
> Thanks for that, but I am still very confused,
>
> Here is my console output and I have attached my classes.
>
> Can you please tell me what i am missing.
>
> Thank you very much.
>
> Chris wade