Accessing ${system(var.name)} variable via framework

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
aujunior
Posts: 40
Joined: Thu Feb 16, 2023 11:00 pm

Accessing ${system(var.name)} variable via framework

Post by aujunior »

Good morning,

We are unregistering some default actions in our framework depending on the context. If the environment is production, we will remove actions like "Author/ShowXML." In the development environment, we will keep all actions.

We used the editor.listen(sync.api.Editor.EventTypes.ACTIONS_LOADED) method along with .unregisterAction(), and it worked perfectly.

However, to detect the production environment, we would like to use a Java system variable that we created. We saw in the documentation that it is possible to access an environment variable using ${system(var.name)}. We need help capturing this variable using the framework directly, without relying on a plugin. We found a way to do this via a plugin that uses the Workspace, but we couldn't achieve the same through the framework.

Could you provide an example of how to access ${system(var.name)} using only the framework?

Thank you for your help.
cristi_talau
Posts: 517
Joined: Thu Sep 04, 2014 4:22 pm

Re: Accessing ${system(var.name)} variable via framework

Post by cristi_talau »

Hello,
In the Java code that belongs to the framework, you can simply use:

Code: Select all

System.getProperty("name")
In the client-side code of a framework you have to make a request to the server to fetch this information, using an AuthorOperationWithResult as described in this tutorial: https://www.oxygenxml.com/maven/com/oxy ... esult.html .
There is another option in which you use a plugin just to make the system property available to the client-side code, but I am not going to explore this option further since you manifested your dislike for using plugins.
Best,
Cristian
Post Reply