Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Explain about using the resolveNode method

Avatar

Former Community Member
I'm trying to understand the use of the resolveNode method that I have read about in the documentation. Both of the following lines of code give the same result.



var whereAmI_1 = TextField1.rawValue;

var whereAmI_2 = xfa.resolveNode("TextField1").rawValue;



So what is the difference and/or why use one over the other? When is resolveNode used?
2 Replies

Avatar

Former Community Member
It depends mostly on where in the DOM your script is running from and where the field you are referencing is.



If the field that you script is on has the same parent as the field you are looking for then referencing it directly (ie: TextField1.rawValue) will work because it will find TextField1.



But if the hierarchy of fields is such that they don't share the same parent then you can use the resolveNode method to find it within the DOM.



ie: xfa.resolveNode("TextField1") finds TextField1 in the DOM starting at the top most node.



xfa.form.formName.pageName.resolveNode("TextField1") will search for TextField1 starting from the pageName node.



etc. etc. etc.



Hope this helps clear it up a bit.



Chris

Adobe Enterprise Developer Support