Concept for custom java interaction

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Concept for custom java interaction

Post by Patrik »

Hi,

I'm using quite some custom implementations of AuthorOperationWithResult to be called by the ActionsManager form the js code.

The documentation of ActionsManager.invokeOperation() claims that on an exception the user will see an error message. Actually this doesn't happen for me. I find the exception i nthe server log but on the client side I get error and result both as null.

So how do I more complex results to the client without parsing a string? For instance a list of objects (in my case a list of key-value-pairs) or an error message?

Thanks and regards,
Patrik
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Concept for custom java interaction

Post by cristi_talau »

The documentation is a bit misleading the exception has to be an instance of "AuthorOpertionException" and its "isOperationRejectedOnPurpose" should return true to be displayed on the client.

Unfortunately, only strings can be passed to the client-side code. Then, as you thought you have to parse it to extract the status of the operation.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Concept for custom java interaction

Post by Patrik »

Hi,

thanks. I've created my own class AuthorOperationOnPurposeException with setOperationRejectedOnPurpose(true) in the constructor and it behaves as expected.

In case anybody else has a similiar problem: I also found a comfortable way to pass my key-value-map to my JS code:
Java:

Code: Select all

import org.codehaus.jackson.map.ObjectMapper;
[...]
final String result= new ObjectMapper().writeValueAsString(map.entrySet().toArray());
JS code:

Code: Select all

[...]
var list = JSON.parse(result);
var length = list.length;
for (var i = 0; i < length; ++i) {
    	var entry = list[i];
        [...]
 }
Regards,
Patrik
Post Reply