Page 1 of 1

Overriding / Enrich arguments in defined actions

Posted: Thu Oct 05, 2023 8:21 pm
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

Re: Overriding / Enrich arguments in defined actions

Posted: Mon Oct 09, 2023 12:18 pm
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.

Re: Overriding / Enrich arguments in defined actions

Posted: Mon Oct 09, 2023 2:17 pm
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

Re: Overriding / Enrich arguments in defined actions

Posted: Mon Oct 09, 2023 3:19 pm
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.

Re: Overriding / Enrich arguments in defined actions

Posted: Mon Oct 09, 2023 3:28 pm
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

Re: Overriding / Enrich arguments in defined actions

Posted: Tue Oct 10, 2023 12:30 pm
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.

Re: Overriding / Enrich arguments in defined actions

Posted: Thu Oct 12, 2023 11:29 am
by Johann
Hello,

Ok, that confirms my initial point.

Thank you,

Johann