Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.
The following page has been changed by StefanoMazzocchi: http://wiki.apache.org/cocoon/JavascriptForJavaProgrammers ------------------------------------------------------------------------------ - Christopher Oliver says ''...In order to reduce the barrier to entry of the Cocoon flow layer for + Christopher Oliver says ''...In order to reduce the barrier to entry of the Cocoon flow layer for - Java programmers that haven't done much with !JavaScript I thought I'd + Java programmers that haven't done much with !JavaScript I thought I'd - give an overview of some of the similarities and differences between + give an overview of some of the similarities and differences between === JavaScript...'' === Read the [http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=104481673824854&w=2 full message] in the cocoon-dev archives. @@ -88, +88 @@ {{{ var x = new String(); }}} - Alternatively you can use the literal syntax to create instances of + Alternatively you can use the literal syntax to create instances of built-in types: {{{ @@ -110, +110 @@ {{{ var n = new java.lang.Integer(3); }}} - All other java packages and classes are accessible under the property + All other java packages and classes are accessible under the property "Packages": {{{ var tree = new Packages.javax.swing.JTree(); }}} - You can get the effect of Java imports using the importPackage() and + You can get the effect of Java imports using the importPackage() and importClass() functions: ||'''In Java:'''||'''In Rhino:'''|||| @@ -143, +143 @@ {{{ // interface to various cocoon abstractions: - - cocoon + - cocoon + - environment // property of type org.apache.cocoon.environment.Environment - - environment // property of type - org.apache.cocoon.environment.Environment - parameters // JavaScript array of <not sure?> - request // property of type org.apache.cocoon.environment.Request - response // property of type org.apache.cocoon.environment.Response - session // property of type org.apache.cocoon.environment.Session - context // property of type org.apache.cocoon.environment.Context + - componentManager // property of type org.apache.avalon.framework.ComponentManager - - componentManager // property of type - org.apache.avalon.framework.ComponentManager - load(fileName) // loads a script - createSession() // attaches this flow script instance to session - removeSession() // detaches this flow script instance from session + // action/input/output module interfaces: - callAction(type, source, parameters) - inputModuleGetAttribute(type, attribute) - outputModuleSetAttribute(type, attribute, value) - // flow API + // flow API - sendPage(uri, bizData); // call presentation layer to present bizData - - sendPageAndWait(uri, bizData, timeToLive) // call presentation layer + - sendPageAndWait(uri, bizData, timeToLive) // call presentation layer to present bizData and - to present bizData and // wait for subsequent request + // action/input/output module interfaces: - act(type, src, param) - inputValue(type, name) @@ -175, +174 @@ // logging support: - print(args) // prints args to standard out + // log object: provides access to cocoon logging system via its methods: - log - error(message) @@ -186, +186 @@ == See Also == * RhinoShell * For a higher level description of the Cocoon objects see: [http://www.webweavertech.com/ovidiu/weblog/archives/000042.html] - * For more on using Rhino for scripting Java see: [http://www.mozilla.org/rhino/scriptjava.html]
