You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by lingerer huang <li...@hotmail.com> on 2006/12/25 12:08:35 UTC

[Help]How to upgrade my Flowscript code

HI,cocooners:
    After cocoon 2.1.10 release,the js_rhino is alse change.I found this
change break many my flowscript code.I want to upgrade my code to make it
run well under 2.1.10 and versions before 2.1.10.I need some help to
complete it.
    1.Exception
	In 2.1.9,I can do this:
	try{
		....
	}catch(e){
		myexceptionProcessor.process(e);
	}
	this wouldn't work in 2.1.10 because e is not Exception now ,it is
org.mozilla.javascript.NativeError now.
       Questions:
	How can I judge whether e is a Exception or NativeError?
	If e is NativeError,how can I get the original Exception?

    2.Class cast in Java
      In 2.1.9 I can do this in Java:
	myobj = (MyClass) cocoon.jsFunction_getComponent(MyClass.ROLE);
      In 2.1.10 the return is org.mozilla.javascript.NativeJavaObject
      Questions:
	How can I get the original Object?

Thanks.


Roy Huang


Re: [Help]How to upgrade my Flowscript code

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

lingerer huang wrote:
>     2.Class cast in Java
>       In 2.1.9 I can do this in Java:
> 	myobj = (MyClass) cocoon.jsFunction_getComponent(MyClass.ROLE);
>       In 2.1.10 the return is org.mozilla.javascript.NativeJavaObject
>       Questions:
> 	How can I get the original Object?
> 
You should not use cocoon.jsFunction_getComponent() in your Java code,
this is a private api for the flow script implementation.

The correct way of getting a component is to use the ServiceManager and
do a lookup(MyClass.ROLE) on a service manager instance. You get the
service manager if you implement the Serviceable interface.

HTH
Carsten
-- 
Carsten Ziegeler - Chief Architect
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/