Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP adding javascript to a java applications

37 views
Skip to first unread message

chris wade orange

unread,
Jun 10, 2008, 10:39:22 AM6/10/08
to dev-tech-js-...@lists.mozilla.org
I keep getting this warning and I cant figure out why.

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

chris idr

unread,
Jun 10, 2008, 11:08:51 AM6/10/08
to dev-tech-js-...@lists.mozilla.org

Ruland Kevin-BHP637

unread,
Jun 10, 2008, 11:17:32 AM6/10/08
to chris wade orange, dev-tech-js-...@lists.mozilla.org
Chris,

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

chris wade orange

unread,
Jun 11, 2008, 7:04:04 AM6/11/08
to Ruland Kevin-BHP637, rhino Dev
Hi I cannot get rid of this error no mater what I do.

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 -

chris idr

unread,
Jun 11, 2008, 12:04:41 PM6/11/08
to Ruland Kevin-BHP637, rhino Dev
Kevin,

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

0 new messages