use rhino require in wsaccess plugin

Post here questions and problems related to oXygen frameworks/document types.
bk-one
Posts: 5

use rhino require in wsaccess plugin

Thu Jan 11, 2018 6:10 pm

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: 5828

Re: use rhino require in wsaccess plugin

Fri Jan 12, 2018 9:55 am

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:

https://www.oxygenxml.com/forum/post41181.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bk-one
Posts: 5

Re: use rhino require in wsaccess plugin

Tue Jan 16, 2018 3:49 pm

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: 5828

Re: use rhino require in wsaccess plugin

Wed Jan 17, 2018 10:26 am

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 1 guest