use rhino require in wsaccess plugin

Post here questions and problems related to oXygen frameworks/document types.
bk-one
Posts: 13
Joined: Mon Oct 23, 2017 3:42 pm

use rhino require in wsaccess plugin

Post by bk-one »

hi,
can you tell me, how to use rhinos require method in an wsaccess javascript plugin?
i would really like to split up my code in smaller "submodules".
best wishes,
barbara
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: use rhino require in wsaccess plugin

Post by Radu »

Hi Barbara,

We are using Rhyno version 1.7.7.1 to run the javascript. I did not manage to find a small example with how that "require" would work.
So right now I cannot give you a solution for writing and using multiple Javascript modules, we are interested in making this work though so probably in a future Oxygen version you will be able to specify in your plugin.xml references to multiple Javascript files which Oxygen will use for the plugin.

In the meantime, if you decide to have multiple Javascript modules you could have a build stage in which you combine all these modules in a single Javascript file which will actually be used.
Or if you want to experiment further you could take full control over the Java code we use to call the Rhyno engine. You can create a Java implementation of the "WorkspaceAccess" plugin extension which calls Rhyno code to invoke methods from a Javascript file:

post41181.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bk-one
Posts: 13
Joined: Mon Oct 23, 2017 3:42 pm

Re: use rhino require in wsaccess plugin

Post by bk-one »

hi,
thanks and sorry for my mistake: require isn't a rhino but a commonjs function which is available in rhino since version 1.7R3.
http://tschaub.net/blog/2011/05/17/comm ... rhino.html

So js.jar already contains the needed code.
https://mozilla.github.io/rhino/javadoc ... quire.html

i hope that somehow helpful.

best wishes,
barbara
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: use rhino require in wsaccess plugin

Post by Radu »

Hi Barbara,

Thanks for the links.
Probably in a future Oxygen version we'll add support for you to declare additional JS modules in the "plugin.xml".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: use rhino require in wsaccess plugin

Post by Radu »

Hi,

We released Oxygen 21.1 and it should allow specifying multiple Javascript module files in the plugin.xml like:

Code: Select all

 <extension type="WorkspaceAccessJS" href="wsAccess.js"/>
 <extension type="WorkspaceAccessJSModule" href="wsAccessModule1.js"/>
 <extension type="WorkspaceAccessJSModule" href="wsAccessModule2.js"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply