AuthorDocumentController.findNodesByXPath returning null after first use

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vitorhugovm
Posts: 22
Joined: Fri Jan 26, 2024 3:31 pm

AuthorDocumentController.findNodesByXPath returning null after first use

Post by vitorhugovm »

Hello!

I'm using a custom renderer called by webappRendererClassName property in CSS.
In two particular element renderers, I need to get attributes values from another element, which I find by using AuthorDocumentController.findNodesByXPath.

When it passes through the first element render, everything goes fine, the element is located and the rest of the function runs normally.
The second render occurs just after the first one, it's a sibling element and it's utilizes the same custom renderer as the first one. The problem is that when it gets to findNodesByXPath function, searching for the same node from before, it returns null.
For instance, there is a function inside this renderer that inserts text in the current element, in addition to rendering some content.

I get the AuthorDocumentController from AuthorInplaceContext.getAuthorAccess().getDocumentController() received by renderControl function in the custom WebappFormControlRenderer.
The context for findNodesByXPath is not specified, what I believe makes it use the root element as context.

What could be happening?

Thanks!
Vitor
cristi_talau
Posts: 509
Joined: Thu Sep 04, 2014 4:22 pm

Re: AuthorDocumentController.findNodesByXPath returning null after first use

Post by cristi_talau »

Hello,

The findNodesByXPath function has a version [1] that receives a context node. If you do not specify the context, it uses the document element.
You mentioned that there is a function in the renderer that inserts text in the document. Does that mean that while rendering you also alter the document? If yes, you should try to find a different solution, because the changes you make during rendering are not reliably reflected in the browser.

Also, notice that if your rendering depends on a sibling element, when that element is modified, the element with the form control will not automatically re-render. You have to use AuthorEditorAccess.refresh(node) (from an AuthorDocumentListener for example) to make sure it re-renders.

If you think there is a bug in the application, please submit a minimal plugin that helps us reproduce your situation using our technical support form: https://www.oxygenxml.com/techSupport.html . Both source code and a compiled plugin will be useful.

Best,
Cristian

[1] https://www.oxygenxml.com/InstData/Edit ... n,boolean)
Post Reply