Webapp 18 set content

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Webapp 18 set content

Post by Konstantin » Thu Jul 21, 2016 6:04 pm

Hi !!!
In Applet we set new content to editor thru:

Code: Select all


final WSEditor editorAccess = editorComponent.getWSEditorAccess();
editorAccess.reloadContent(new StringReader(xmlContent), false);
Now in Webapp 18 I try do it thru this:

Code: Select all


private AuthorDocumentModel documentModel;
...
documentModel.getWSEditor().reloadContent(new StringReader("99999999999"), false);
But it does not works and I can't find opportunity to do it.
How can I do it?

Gabriel Titerlea
Posts: 40
Joined: Thu Jun 09, 2016 2:01 pm

Re: Webapp 18 set content

Post by Gabriel Titerlea » Fri Jul 22, 2016 11:12 am

Dear Konstantin,

The Web Author client does not know that the server model has changed unless it asks for the specific information.
I have added an issue for your request and it should be available in the next maintenance build (about 3 weeks from now).

The new API will allow you to synchronize the content of the client with the content of the document from the server.
The API is already available in version 18 but it's not documented and it doesn't work with full-tags sentinels mode.

You can test it right now by calling the editor.restoreContent() method using javascript [1].

You can save a reference to the editor instance by listening for the EDITOR_LOADED event:

Code: Select all


(function () {
goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
// Save the editor for later use.
var editor = e.editor;
});

// At a later time, when you need to restore the content of the client editor, you can call:
try {
editor.restoreContent();
} catch (e) {
// Note: The method will throw a benign error in version 18 so you might want to wrap it inside a try-catch
}
})();
If you are developing a plugin for Web Author, you only need to add a javascript file to a web folder inside your plugin and it will be loaded into the Web Author.

[1] - https://www.oxygenxml.com/maven/com/oxy ... index.html

Regards,
Gabriel

Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Webapp 18 set content

Post by Konstantin » Fri Jul 22, 2016 3:53 pm

Ok thanks, we will wait.

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp 18 set content

Post by aleh.haidash » Thu Nov 10, 2016 1:16 pm

Gabriel Titerlea wrote:Dear Konstantin,

The Web Author client does not know that the server model has changed unless it asks for the specific information.
I have added an issue for your request and it should be available in the next maintenance build (about 3 weeks from now).

The new API will allow you to synchronize the content of the client with the content of the document from the server.
The API is already available in version 18 but it's not documented and it doesn't work with full-tags sentinels mode.

You can test it right now by calling the editor.restoreContent() method using javascript [1].

You can save a reference to the editor instance by listening for the EDITOR_LOADED event:

Code: Select all


(function () {
goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
// Save the editor for later use.
var editor = e.editor;
});

// At a later time, when you need to restore the content of the client editor, you can call:
try {
editor.restoreContent();
} catch (e) {
// Note: The method will throw a benign error in version 18 so you might want to wrap it inside a try-catch
}
})();
If you are developing a plugin for Web Author, you only need to add a javascript file to a web folder inside your plugin and it will be loaded into the Web Author.

[1] - https://www.oxygenxml.com/maven/com/oxy ... index.html

Regards,
Gabriel
Hello.
I tried use this solution, but it doesn't work.
I use doc url like this http://<host>/webapp_editor?sourceDocPath=<path to document>. After opening document i recieve request on my servlet (webapp_editor), but after calling editor.restoreContent() the request didn't come.
How can I send request for refreshing content in editor using servlet?
Best Regards,
Aleh

Gabriel Titerlea
Posts: 40
Joined: Thu Jun 09, 2016 2:01 pm

Re: Webapp 18 set content

Post by Gabriel Titerlea » Fri Nov 11, 2016 2:54 pm

Hello,

First, a few explanations:

During an editing session with Web Author 3 versions of a file are used:
- The original file stored on disk [_]
- The file from disk stored in the server memory [s]
- The file from disk stored in the browser memory

The two versions, [s] and , are constantly synchronised. However it is possible to make changes to the server version [s]
without the browser knowing about it. In this case we will call editor.restoreContent to synchronize the content from the server [s]
with the content from the browser .

The original file [_] is only modified when one saves the document or when one initially opens the file for editing.

That being said if you want to refresh the content from content references you can use this method:
post39974.html#p40382

If you will open a file which contains a conref to another file and you will use the method linked above you will notice that
Web Author will make a request for the referred file and will bring the content into the currently opened document in the browser.

Because editor.restoreContent is not marked as API and is subject to change I would suggest to avoid using it.


Best,
Gabriel

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp 18 set content

Post by aleh.haidash » Fri Nov 11, 2016 5:34 pm

I understood.
But I have a case like this:
1) User 1 opens document in Webapp in readOnly mode
2) User 2 opens this document in editing mode -> add some changes -> save document
3) Send a event to user 1 with notifocation.
How can I refresh content for user 1 (without reopening the tab)?
Best Regards,
Aleh

Gabriel Titerlea
Posts: 40
Joined: Thu Jun 09, 2016 2:01 pm

Re: Webapp 18 set content

Post by Gabriel Titerlea » Fri Nov 11, 2016 6:21 pm

I understand.
It's not possible to do that at the moment but I will add your vote to the issue for implementing this.

Best,
Gabriel

aleh.haidash
Posts: 32
Joined: Tue May 26, 2015 10:28 am

Re: Webapp 18 set content

Post by aleh.haidash » Mon Feb 26, 2018 5:18 pm

Hello.
I would like to raise this issue again.
Are this feature available in 19.1?

BR,
Aleh
Best Regards,
Aleh

Gabriel Titerlea
Posts: 40
Joined: Thu Jun 09, 2016 2:01 pm

Re: Webapp 18 set content

Post by Gabriel Titerlea » Mon Feb 26, 2018 6:38 pm

Hello,

In 19.1 you can reload the content of a document by invoking the ReloadContentOperation[1] operation.

You can invoke this operation from a javascript plugin like this:

Code: Select all

editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.ReloadContentOperation', {},
function () {
console.log('content reloaded')
}
);
You might find this tutorial useful as well [2][3].

Best regards,
Gabriel

[1] https://www.oxygenxml.com/InstData/Edit ... ation.html
[2] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[3] https://www.oxygenxml.com/maven/com/oxy ... nager.html

Post Reply