Page 1 of 1

use rhino require in wsaccess plugin

Posted: Thu Jan 11, 2018 6:10 pm
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

Re: use rhino require in wsaccess plugin

Posted: Fri Jan 12, 2018 9:55 am
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

Re: use rhino require in wsaccess plugin

Posted: Tue Jan 16, 2018 3:49 pm
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

Re: use rhino require in wsaccess plugin

Posted: Wed Jan 17, 2018 10:26 am
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

Re: use rhino require in wsaccess plugin

Posted: Thu May 23, 2019 2:34 pm
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