These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Malformed SOM expression

StevenD
Registered: Oct 6 2006
Posts: 368
Answered

I'm trying to get the border of the fillable area of a text field to change color. So far the only way I have found to get all four sides to change is by using the following lines of code.

xfa.resolveNode("TextField1.ui.#textEdit.border.edge[0].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[1].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[2].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[3].color").value = "0,255,0";

I thought maybe I could use a for loop to do the same thing as in the following.

for(var i = 0; i < 3; i++)
{
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[i].color").value = "0,255,0";
}

But I get the following error when I click the button that the script is attached to.

GeneralError: Operation failed.
XFAObject.resolveNode:6:XFA:form1[0]:MainPageSF[0]:Button1[0]:click
Malformed SOM expression: TextField1.ui.#textEdit.border.edge[i].color

I don't know what is happening. Any ideas why a for loop doesn't work in this case?

StevenD

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The variable "i" is inside the string so it's not being resolved. It should be:

for(var i = 0; i < 3; i++)
{
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[" + i + "].color").value = "0,255,0";
}

Or you could do it like this:

var nodes = xfa.resolveNode("TextField1.ui.#textEdit.border.edge[*].color");

for(var i = 0; i < 3; i++)
{
nodes.item(i).value = "0,255,0";
}

However, you shouldn't have to access all of the edges unless it was setup like this in the first place. Have you looked at the original XML to see how the field was initially structured?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

StevenD
Registered: Oct 6 2006
Posts: 368
Thanks Thom.

I haven't taken a look at the original XML but I will. I have never been able to get all of the sides of the fillable area to change color. Usually it is only one side. I have tried now to get the border to change color with a single line of code like you can to set the fill color but with no success. Some other folks have had the same problem. There is no problem getting the border of the field itself to change color.

the text field I added to the page orginally had the 3D border (default) and I had to change it to solid.

What would I be looking for in the structure of the field to see how the field was initially structured?

StevenD

StevenD
Registered: Oct 6 2006
Posts: 368
Here is what the XML of the field shows.

Text FieldSince the color of the solid border is black there is nothing showing that indicates color. I went into the UI and manually changed the color to a bright green. When I checked the XML the showed up. I tried to run the code as follows to see what would happen.

xfa.resolveNode("TextField1.ui.#textEdit.border.edges.color").value = "255,0,0";

When I clicked the button that has this code in the Click event I got a fillable area with a red top edge and left, right, and bottom edges but not all four sides.

StevenD

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I was able to change the border color by setting the appearance on the Oject/Field tab to "None" and then using this code.

xfa.form.form1.pg1.TextField2.ui.textEdit.border.edge.color.value = "255,0,0"
xfa.form.form1.pg1.TextField2.ui.textEdit.border.presence = "visible"

When I set the appearnce to "Solid" the same code only changed one edge. Using other appearnce settings shut off all color modification from code. Changing the values on the "Border" tab made no difference to any of this.

I think the problem is that setting the field appearance to a specific value gives Acrobat license to setup some fancy inaccessible structure for the field appearance. But setting it to "None" gives a script control.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

StevenD
Registered: Oct 6 2006
Posts: 368
Finally this thing get cracked. It looks like there are a couple of ways to do this. This last procedure you give works very well.

Thanks for the help.

StevenD