Expand my Community achievements bar.

SOLVED

xfa.resolveNode question

Avatar

Level 1

I have a function that takes 2 arguments, the first is a XFAObject and it doesn't really matter what the second one is. I use the first parameter to set a variable inside a call to xfa.resolveNode(): xfa.resolveNode(x). My variable is a concatination of the parameter and the instanceIndex all in between single quotes of that parameter: x = String.concat("'", param1, "[", param1.instanceIndex, "]'");

When put together it looks like this:

function MyFunction(param1, param2) {

     var j = param1.instanceIndex;

     var x = String.concat("'", param1, "[", j, "]'");

     xfa.resolveNode(x).presence = "visible";

}


Could someone tell me why this isn't working? I checked the values of all my variables and they were all correct, but when it doens't seem to work in the xfa.resolveNode();

1 Accepted Solution

Avatar

Correct answer by
Level 6

I think your issue might be due to where in the hierarchy your new object lies.  xfa.resolveNode starts its search at the top of the Form hierarchy and may not find the node if it is layered under other objects and you don't have them in the path.

However, there is a simpler way to do what you want without the resolveNode.  instanceManager.insertInstance returns the object that you are inserting, and you can access it directly.  Just do the following:

     var newPage = page.instanceManager.insertInstance(j, 0);

     newPage.presence = "visible";

View solution in original post

9 Replies

Avatar

Former Community Member

Just a quick thought before I head out for the weekend!

XFA ResolveNode requires a string and you are passing in an Object. In your concat woudl you not need to say param1.name to get the name of your obect? Or param1.somExpression to get the full path of your object? If you are passing a string in as param1 then my advice does not apply.

Paul

Avatar

Level 6

From the looks of your code, you're probably passing in some sort of object (like an instance of a subform) which is an object.  If you did an app.alert (x) in your method you'd probably see something like "object xfaObject[0]".

Try :

var x = String.concat("'", param1.name, "[", j, "]'");

Avatar

Level 1

Thanks, to both of you for your quick response. I tried using param1.name and the app.alert now correctly displays 'Page20' as the value of param1, and 'Page20[1]' for x. However, the code is still failing at the xfa.resolveNode part. Here is my entire code to check if I've got anything else missing:

function contWithCheckBox(page, focus) {
     xfa.host.messageBox("You have called the function contWithCheckBox()");
     var j = page.instanceIndex + 1

    xfa.host.messageBox(String.concat("You have set the instanceIndex for ", String(page.name)));
     var page_instance = String.concat("'", page.name, "[", j, "]'");   
     xfa.host.messageBox(page_instance);
    
     if (page.Group1.continue.rawValue == 1) {
         xfa.host.messageBox("You are in the first if statement");
         page.instanceManager.insertInstance(j, 0);
         xfa.host.messageBox("Instance inserted");
         xfa.resolveNode(page_instance).presence = "visible";
         xfa.host.pageDown();
         xfa.host.setFocus(focus);
         xfa.host.messageBox("SUCCESS!");
     } else if (page.Group1.continue.rawValue == 0) {
         page.instanceManager.removeInstance(j);
     }
}

So you can see I've set up some test points. All of the messageBox calls fire except the final one that says "SUCCESS!", unless I comment out the xfa.resolveNode. somExpression wouldn't work for me in the case because it also retrieves the instanceIndex which is part of my String.concat().

Thanks again.

Avatar

Correct answer by
Level 6

I think your issue might be due to where in the hierarchy your new object lies.  xfa.resolveNode starts its search at the top of the Form hierarchy and may not find the node if it is layered under other objects and you don't have them in the path.

However, there is a simpler way to do what you want without the resolveNode.  instanceManager.insertInstance returns the object that you are inserting, and you can access it directly.  Just do the following:

     var newPage = page.instanceManager.insertInstance(j, 0);

     newPage.presence = "visible";

Avatar

Level 1

Hi Kevin,

Maybe I should do this in the older version of Acrobat, with the older form fields tool. I'm not that familiar with the coding aspects of Live Cycle. What do you think about that?

Thanks,

Sarah

Avatar

Level 6

Dunno Sarah, depends.  If you're more comfortable with the older tool and it will produce the output that you want, then maybe go with that.  However the change above should fix the ResolveNode issue.  Is there something else that's not working?  If you're not super pressed for time, getting on board with LiveCycle might be a good idea.

Avatar

Level 1

Hi Kevin,

Thanks for the input. Fantastic. Works fine and will cut down my code by a few lines. Do you know of any good LiveCycle script reference books? I've been using web JavaScript for a few years now but need something to give me a better idea of what I can and can't do in LiveCycle.

Thanks,

Chow

Avatar

Level 6

Chow, I haven't personally read any books, but people in forums and blogs seem to have good things to say about the book "Creating Dynamic Forms with Adobe LiveCycle Designer" by JP Terry.

Like you I already knew Javascript so I just spent some time reviewing the Adobe Livecycle developer documentation to understand the object models.  The docs are a bit sparse and lack good examples, but between those and the forums you can get a pretty good idea of how to do things.

Kevin

Avatar

Level 1

Yea, I have that book and just haven't had the time to look through it except briefly. I agree the documentation is a bit sparse; enough to get started but not enough to really learn the stuff inside and out.

Chow