ResolveNode/Find node? | Community
Skip to main content
New Participant
August 1, 2006

ResolveNode/Find node?

  • August 1, 2006
  • 17 replies
  • 5767 views
Hello!



I was wondering if there is a function to find a field by name in a PDF.

I already saw a lot of examples using Resolvenode, however, these examples always used the path to the node (page.subform.etc). Because I don´t know where the field will be or even if the fields really exists, I would like to search for it easily. The only solution I had found was to interact through all the nodes on each page, but this seems not very efficient.



Thank you
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

17 replies

August 3, 2006
Part of the confusion I have been having is coming from Acrobat JavaScripting where the field names are always in quotes and they aren't using JavaScript for Designer. By the way what is this brand of JavaScript really called? Is it xfa JavaScript?



Thanks for all the help on increasing my understanding. You folks at Adobe are great job.
neptasAuthor
New Participant
August 3, 2006
Chris,



Great help. Thankx
August 3, 2006
Let's say the response is stored in a variable named myFieldNum it would look like:



form1.mainPage.resolveNode("mySubForm[1].Field" + myFieldNum).rawValue = "Test";



Just remember, resolveNode searches through nodes in the DOM looking for the one you want. It's not great for performance. So only use it when you need to, and whenever possible use it such that it will start looking in a position where it will find the node you want as soon as possible.



Chris

Adobe Enterprise Developer Support
August 2, 2006
Thanks for the new info. This discussion is really helping. I have been playing around with this in various ways and have come up with several ways to do basically the same thing.



//This works.

form1.mainPage.resolveNode("mySubForm[1]").Field3.rawValue = "Yes";



//This works.

var nodeList = form1.mainPage.resolveNodes("mySubForm[*]");

nodeList.item(1).Field3.rawValue = "Yes";



//This works.

var myFld = xfa.resolveNode("form1..mySubForm[1].Field3");

myFld.rawValue = "Yes";



//This works.

xfa.resolveNode("form1..mySubForm[1]").Field3.rawValue = "Yes";



Here is something else.

I was even trying to get a user response to work in the following example.



var mySubF = xfa.host.response("Which Subform instance?", "", "");

xfa.resolveNode("form1..mySubForm[" + mySubF + "]").myFld3.rawValue = myV;



So I can get the user to key in a number in the response dialog that come up specifying which subform use. But how do I combine a response with part of the field name as in Field 1, 2, or 3. So if the user keys in 3 then 3 is put together with Field to get Field3?
August 2, 2006
Ok, apparently resolveNode() works a little different from what I thought, and I just learned something new, so thanks :d



The way resolveNode() works is it will start from the node that it is called from. So xfa.resolveNode() starts from top level. Whereas, xfa.form.formName.subForm1.subForm2.resolveNode() would start from the subForm2. At this point it will look at all nodes that share the same parent as the one from which it is called from. If it doesn't find what it's looking for it will then traverse UP the tree to look for it (yes, UP, not down). That's why it doesn't find your TextField1, because it is lower in the tree than the top level...



So at this point you may react as I did and say something like "Wow, searching UP a tree is $@#%$# useless". Well, it might actually be useful in some circumstances, and luckily there is a notation you can use to make it search down the tree too. If you do something like:



xfa.resolveNode("form1..TextField1");



This tells it to start at form1 (you'd rename this to whatever you top level form node is called) and the .. says look DOWN and find TextField1. So if you use that on your form you will be able to find TextField1 regardless of where it is on the form.



Chris

Adobe Enterprise Developer
August 2, 2006

August 2, 2006
I see what you mean. It "should" work, but it obviously isn't. I'm looking into it.



Chris

Adobe Enterprise Developer Support
neptasAuthor
New Participant
August 2, 2006
Ok,



I got it. If you rename the subForm where the text field is, you get the null value. How come?
neptasAuthor
New Participant
August 2, 2006
Hi,



It works... However, if I had a subform from my Designer... it will not work again. I´m using designer 7.0. However, I tried in Designer 7,1 and the problem persist...



When I place a new subform at the form the subform gets call SubForm1 and not (untitled Subform). Can be this a clue for the error?



Thank you
August 2, 2006
Ok, try this form then. Does it work for you? It does for me. What's different between my form and yours?



Chris

Adobe Enterprise Developer Support