Trigger update/refresh in oxygen web author
Oxygen general issues.
-
- Posts: 42
- Joined: Tue Jun 08, 2021 3:27 pm
Trigger update/refresh in oxygen web author
Post by Srinarayan »
Hi Team,
We are currently calling an API call which is asynchronous so that it wont delay the loading of documents. Based on the content received from the API call we are enabling/disabling a button in the toolbar. As it is an async call to the API the button is enabled by default as it doesn't have to wait for the API.
But when we click/focus in the editor manually the button is updating itself based on the content from the API. I think an update/refresh function is happening after focusing/clicking on an element in the editor. So in order for us enable/disable the button without having to click/focus and element manually, is there anyway we can call this update/refresh on the editor so that our button is synced? Please help.
Regards,
Srinarayan
We are currently calling an API call which is asynchronous so that it wont delay the loading of documents. Based on the content received from the API call we are enabling/disabling a button in the toolbar. As it is an async call to the API the button is enabled by default as it doesn't have to wait for the API.
But when we click/focus in the editor manually the button is updating itself based on the content from the API. I think an update/refresh function is happening after focusing/clicking on an element in the editor. So in order for us enable/disable the button without having to click/focus and element manually, is there anyway we can call this update/refresh on the editor so that our button is synced? Please help.
Regards,
Srinarayan
-
- Posts: 81
- Joined: Wed Jul 20, 2016 8:22 am
Re: Trigger update/refresh in oxygen web author
Post by mihai_coanda »
Hello,
The toolbar item reflects the action it represents enable/disabled status[1] so if the isEnabled method of the action returns true the item will be reactivated.
In your case, the action should return whether it is enabled or disabled based on the data received from the request.
We do not provide any API to disable a toolbar's item as it is tied to the action. What is the JS code you are executing to disable the toolbar item?
A more detailed description of your scenario would help us come up with a more suitable solution for your use case.
Best Regards,
Michael
1. https://www.oxygenxml.com/maven/com/oxy ... ction.html
The toolbar item reflects the action it represents enable/disabled status[1] so if the isEnabled method of the action returns true the item will be reactivated.
In your case, the action should return whether it is enabled or disabled based on the data received from the request.
We do not provide any API to disable a toolbar's item as it is tied to the action. What is the JS code you are executing to disable the toolbar item?
A more detailed description of your scenario would help us come up with a more suitable solution for your use case.
Best Regards,
Michael
1. https://www.oxygenxml.com/maven/com/oxy ... ction.html
Michael
https://www.oxygenxml.com
https://www.oxygenxml.com
-
- Posts: 42
- Joined: Tue Jun 08, 2021 3:27 pm
Re: Trigger update/refresh in oxygen web author
Post by Srinarayan »
Hi Michael,
This is my code snippet which I am using for enabling/disabling the button:
The call is an asynchronous call. Please let me know if you need additional info.
Regards,
Srinarayan.
This is my code snippet which I am using for enabling/disabling the button:
Code: Select all
function getContent(param1, param2) {
try {
var xhttp = new XMLHttpRequest();
xhttp.onload = function() {
arr1 = JSON.parse(this.responseText);
URN.prototype.isEnabled = function() {
if (arr1 != undefined) {
return true;
} else {
return false;
}
}
//Have to trigger the button enabling/disabling here.
};
xhttp.open("GET", "API-URL", false);
xhttp.setRequestHeader("authorization", authID);
xhttp.setRequestHeader("accept", "application/json");
xhttp.send();
} catch {
console.log("Error");
}
}
Regards,
Srinarayan.
-
- Posts: 81
- Joined: Wed Jul 20, 2016 8:22 am
Re: Trigger update/refresh in oxygen web author
Post by mihai_coanda »
Hello,
To update the toolbar button's enabled/disabled status without moving to the document you can use the ActionsManager.refreshActionsStatus JS API.
Best Regards
Michael
1. https://www.oxygenxml.com/maven/com/oxy ... us__anchor
To update the toolbar button's enabled/disabled status without moving to the document you can use the ActionsManager.refreshActionsStatus JS API.
Best Regards
Michael
1. https://www.oxygenxml.com/maven/com/oxy ... us__anchor
Michael
https://www.oxygenxml.com
https://www.oxygenxml.com
-
- Posts: 42
- Joined: Tue Jun 08, 2021 3:27 pm
Re: Trigger update/refresh in oxygen web author
Post by Srinarayan »
Hi Michael,
Thanks for the help. It worked.
Just a thought-> can we create another thread apart from the main one that loads the documents and toolbar actions so that we could call our API synchronously but on another thread.
For Example : the main thread would load all the toolbar actions and document content and another thread would simultaneously call the API and then additionally do some updates
Please let me know if we can do that.
Regards,
Srinarayan
Thanks for the help. It worked.
Just a thought-> can we create another thread apart from the main one that loads the documents and toolbar actions so that we could call our API synchronously but on another thread.
For Example : the main thread would load all the toolbar actions and document content and another thread would simultaneously call the API and then additionally do some updates
Please let me know if we can do that.
Regards,
Srinarayan
-
- Posts: 81
- Joined: Wed Jul 20, 2016 8:22 am
Re: Trigger update/refresh in oxygen web author
Post by mihai_coanda »
Hello,
Javascript has a single-threaded nature.
You could use javascript as a Web Worker to execute scripts from an HTML page that runs on a background thread away from the main execution thread.
I suspect that running your API synchronously using a Web Worker would not help you too much compared with the asynchronous invocation as your code does nothing during the request.
Our application does not have heavy code that throttles the js thread and the loading time is mainly caused by waiting for responses from the server time in which JS the thread is free.
Best Regards,
Michael
Javascript has a single-threaded nature.
You could use javascript as a Web Worker to execute scripts from an HTML page that runs on a background thread away from the main execution thread.
I suspect that running your API synchronously using a Web Worker would not help you too much compared with the asynchronous invocation as your code does nothing during the request.
Our application does not have heavy code that throttles the js thread and the loading time is mainly caused by waiting for responses from the server time in which JS the thread is free.
Best Regards,
Michael
Michael
https://www.oxygenxml.com
https://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service