Overriding / Enrich arguments in defined actions

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Overriding / Enrich arguments in defined actions

Post by Johann »

Hello,

We're using Author web 25.1.0.0 version.


From the javascript, we want to call an operation
https://www.oxygenxml.com/doc/versions/ ... soperation


Its purpose is to perform a sequence of operations defined in the framework via the list of actionIds passed as parameter.

This works well for fragment insertion actions with fixed arguments.

The complexity of our requirement is that the various operations to be performed depend on the input data carried by the javascript.

In fact, we need to enrich certain fragments to be inserted with javascript information.

Example of a called XML operation defined in the framework:

Code: Select all

<a:operationid="InsertFragmentOperation">
<a:arguments>
<a:argumentname="fragment"><entry><para>${valueFromJavascript}</para></entry></a:argument>
<a:argumentname="insertLocation">ancestor-or-self::entry[1]</a:argument>
<a:argumentname="insertPosition">After</a:argument>
</a:arguments>
</a:operation>
We want to take advantage of the framework's existing mechanism for defining actions and operations, but also be able to override certain arguments OR enrich certain arguments with information contained in the javascript.

Does this sound feasible?

Thanks for your help,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Overriding / Enrich arguments in defined actions

Post by Bogdan Dumitru »

Hello,

One solution would be that instead of invoking ExecuteMultipleWebappCompatibleActionsOperation, define a custom AuthorOperation and from that operation manually call the other operations. You can pass to the custom operation your valueFromJavascript and then you can pass/dispatch it to another operation when invoking. To manually call another operation you have to simply instantiate it and call its "doOperation" method.
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Overriding / Enrich arguments in defined actions

Post by Johann »

Hello Bogdan,

thank you for your response.

In the last part of your response, you say:
You can pass to the custom operation your valueFromJavascript and then you can pass/dispatch it to another operation when invoking. To manually call another operation you have to simply instantiate it and call its "doOperation" method.
I agree but the invoked operation is not defined in the .framework file in that case, is it ?

As I was saying, I'm trying to find a way of having my actions defined in the .framework file, but being able to inject information into the operation arguments of that action.

Thank you,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Overriding / Enrich arguments in defined actions

Post by Bogdan Dumitru »

Hi,
One correction: in the .framework you can only define actions, not operations. Operations are Java classes that implement the AuthorOperation interface.
The above solution doesn't work if you want to reuse actions defined in the framework because it works just with operations.
Another solution would be to use ask variables and let the user fill in the value for valueFromJavascript. Notice that ExecuteMultipleOperations is not annotated with @WebappCompatible, thus if you define actions and add them on the toolbar they won't be visible on Web Author, so you should use ExecuteMultipleWebappCompatibleActionsOperation instead.
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Overriding / Enrich arguments in defined actions

Post by Johann »

Hello,
Another solution would be to use ask variables and let the user fill in the value for valueFromJavascript
The only way to populate ask variables is through a user form, right? Or is there another way?
So, in my case, the valueFromJavascript corresponds to a response of a webservice and not a user choice.

Regards,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Overriding / Enrich arguments in defined actions

Post by Bogdan Dumitru »

Hi,

The only solution is to invoke each action individually, and for the ones that need valueFromJavascript to invoke the actual operation with valueFromJavascript as an argument.
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Overriding / Enrich arguments in defined actions

Post by Johann »

Hello,

Ok, that confirms my initial point.

Thank you,

Johann
Post Reply