Form control - how to replace text using Author Mode Operations?

Oxygen general issues.
catominor
Posts: 7
Joined: Mon May 02, 2022 11:48 am

Form control - how to replace text using Author Mode Operations?

Post by catominor »

Hi,
I want to use the combobox that changes simultaneously two different values (I am using Oxygen 20.1):
1) A @key value of the <author> - this works perfectly with label and value
2) Name of the author within the element <author> - and I cannot achieve that.

What I tried was to add onChange parameter to the oxy_combobox, and then pair oxy_action with onChange with operation, 'InsertOrReplaceFragmentOperation'. However, this does not work:

Code: Select all

 onChange, oxy_action(
                name, 'Replace ',
                operation, 'InsertOrReplaceFragmentOperation',
                arg-fragment, 'Placeholder name',
                arg-insertLocation, './text()',
                arg-insertPosition, 'Replace'   )
            
            );
(My third future step is to replace "Placeholder name" with oxy_xpath that would find the name of the author in another .xml file using @key.)

I also tried other insertLocation xpaths but without success.

Any idea? :)
Thank you very much in advance!
Jan
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Form control - how to replace text using Author Mode Operations?

Post by alex_jitianu »

Hello,
I tried this myself and what I observed was that a new "Placeholder name" part was inserted instead of replacing the entire content. Is this what happens in your case as well? It does this because the operation only replaces the selection and in this case you have no selection. In the later version of Oxygen we added another operation, ReplaceElementContentOperation, which behaves like you desire. For 20.1 you can use JSOperation or XQueryUpdateOperation:

Code: Select all

p {
    content: oxy_combobox( 
            edit, '@attribute',
            editable, false,
            values, 'value1, value2, value3',
            labels, 'Value no1, Value no2, Value no3',
             onChange, oxy_action(
                name, 'Replace ',
                operation, 'XQueryUpdateOperation',
                arg-script, 'replace value of node . with "Placeholder name"'
                )
)
}
Best regards,
Alex
catominor
Posts: 7
Joined: Mon May 02, 2022 11:48 am

Re: Form control - how to replace text using Author Mode Operations?

Post by catominor »

Dear Alex,
thank you very much :).
Now I will hopefully manage it!
Best regards,
Jan
Post Reply