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

Scripts for the Master Page

ActuaryGuy
Registered: May 15 2009
Posts: 3

One of the scripts in my document (not on the master page) will change all of the text boxes from English to French. The Master Page holds a header. When the translate script fires I would like for the header to be translated as well. To make that happen I run:

form1.resolveNode("#pageSet[0].Header.Title1.value.#text").value = "MY TEXT";

There are two problems:

1) Only the header on the first page changes. As per Thom Parker, I see that I will need to reference that header on each of my pages; however, he did not provide an example of how to do it. So, how do I do it?

2) My script will run and the header (on page 1) will change. However, as soon as I select one of the radio buttons on page 1, the header reverts to the state that the file opened in. Selecting a radio button on a different page will not affect anything. How can I get the changed title to stick?

Thanks,

~ Nick ~

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
To show/hide elements on every instance of a masterpage you need a for expression.

In this example there are two subforms called "English" and "French" on the masterpage.
The SOM path on the masterpage for example is "xfa.resolveNode("Form1.#pageSet.1.English" and/or "xfa.resolveNode("Form1.#pageSet.1.French".
With a script like this on a buttons click event, you can control the visibility of the subforms in the whole form.

  1. for (var i = 0; i < xfa.host.numPages; i++)
  2. {
  3. var oSubform = xfa.resolveNode("Form1.#pageSet.1[" + i + "]");
  4.  
  5. oSubform.English.presence = "hidden";
  6. oSubform.French.presence = "visible";
  7. }

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

noos
Registered: Aug 28 2009
Posts: 20
radzmar wrote:
To show/hide elements on every instance of a masterpage you need a for expression.In this example there are two subforms called "English" and "French" on the masterpage.
The SOM path on the masterpage for example is "xfa.resolveNode("Form1.#pageSet.1.English" and/or "xfa.resolveNode("Form1.#pageSet.1.French".
With a script like this on a buttons click event, you can control the visibility of the subforms in the whole form.

for (var i = 0; i < xfa.host.numPages; i++){var oSubform = xfa.resolveNode("Form1.#pageSet.1[" + i + "]"); oSubform.English.presence = "hidden";oSubform.French.presence = "visible";}
Hello I used this script to hide an object located in the master page
Click event of the button, the object is hidden

in the same button I have to hide another object
example click of button:

for (var i = 0; i
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
@noos

The script will not work, if you try to manipulate objects on the masterpages and other pages together from one button event.
It also won't work if you put one script for the masterpages to the mouse down event and the script for the other pages to the mouse up event.
You will need to manipulate the field "verifica" in another way.
Until now, I found no way to do this with one mouse click.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

noos
Registered: Aug 28 2009
Posts: 20
I understand and what can I do
noos
Registered: Aug 28 2009
Posts: 20
hi radzmar I did a test

In your opinion is correct as I did???

[url=http://forums.adobe.com/servlet/JiveServlet/download/2213619-18649/example.pdf]link[/url]
Scriptron
Registered: May 18 2010
Posts: 3
This was very helpful, thank you.
krm240
Registered: Apr 17 2009
Posts: 95
Radzmar
from your comments it sounds like one can not manipulate the master page (sat hide a field) and perform other actions to hide other fields on the main doc using the same button action.
I am experiencing this issue now and trying to resolve.

Is there a standard work around method that people use?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can outsource your scripts for master pages and body pages into script objects.

Example:
Create a script object under the root node of your form (form1) and name it "MyScripts".
Then add functions with your individual scripts.

  1. function EnglishToFrench()
  2. {
  3. for (var i = 0; i < xfa.host.numPages; i++)
  4. {
  5. var oSubform = xfa.resolveNode("Form1.#pageSet.1[" + i + "]");
  6.  
  7. oSubform.English.presence = "hidden";
  8. oSubform.French.presence = "visible";
  9. }
  10. }
  11.  
  12. function FrenchToEnglish()
  13. {
  14. for (var i = 0; i < xfa.host.numPages; i++)
  15. {
  16. var oSubform = xfa.resolveNode("Form1.#pageSet.1[" + i + "]");
  17.  
  18. oSubform.English.presence = "visible";
  19. oSubform.French.presence = "hidden";
  20. }
  21. }

To execute the scripts you only need to reference to the functions in your script object.
This can be done by a small JavaScript snippet in a button click event for example.
MyScripts.EnglishToFrench();
The advantage is that you can execute several scripts successive with one button click, no matter if they affect something on the master pages or body pages.

  1. MyScripts.DoSomethingOnMasterpage();
  2. MyScripts.DoSomethingOnBodyPage();
  3. ...

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

krm240
Registered: Apr 17 2009
Posts: 95
Something here is not working
Understand about scripts, using them.
The issue is creating a script that will modify the Master page AND make fields visible/hidden in the main body of the form.
Individually, each script works, but not together
ie: if you comment out one line or the other, script will hide the Deadlines btn on the MP, OR Script will hide the Text field, but will not do BOTH

Example
I have a Navigation bar on the master page
Say 3 Buttons with text "A" "Deadlines" "C"
All buttons initially visible

I have 1 Text fields on Page1 Called "SName"

I also have 3 CheckBoxes on Page1 Called "Show Deadlines"
Code in the CheckBoxes to run code as follows:
Hide the appropriate Navigation Btn (in this case Deadlines) on the master Page
and
Hide the appropriate Text field on Page1, in this case "SName"
Actual code for one CheckBox is as follows:
if(this.rawValue == 1) MasterPage.ShowDeadlines(); else MasterPage.HideDeadlines();
if(this.rawValue == 1) MasterPage.ShowField(); else MasterPage.Hidefield();


MyScripts Code is as follows:
function HideDeadlines()
{
for (var i = 0; i < xfa.host.numPages; i++)
{
var nMasterPages = xfa.resolveNode("xfa.form.Main.Master.Page1[" + i + "]");
nMasterPages.Navlist.BtnDeadlines.presence = "hidden";
}
}// End of script
function ShowDeadlines()
{
for (var i = 0; i < xfa.host.numPages; i++)
{
var nMasterPages = xfa.resolveNode("xfa.form.Main.Master.Page1[" + i + "]");
nMasterPages.Navlist.BtnDeadlines.presence = "visible";
}
}// End of script
function ShowField()
{
Main.P1.SName.presence = "visible";
}// End of script
function Hidefield()
{
Main.P1.SName.presence = "hidden";
}// End of script


Yes - some code could be improved upon for effeciency, but just trying to get it to work first :-)
If anyone can shed some light on this, would appreciate it.

The issue is how to hide fields on the Master Page AND hide text on the Main form from one Button click?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

maybe you need to change your scripts to reference the form objects.
I have several forms where I can change form objects on master pages and body pages with one click.
Try scripts in this manner to resolve your form objects.

  1. function HideDeadlines()
  2. {
  3. for (var i = 0; i < xfa.host.numPages; i++)
  4. {
  5. var sSOM = "Main.Master.Page1[" + i + "].Navlist";
  6. var oFields = xfa.resolveNode(sSOM);
  7. oFields.Lock.presence = "hidden";
  8. }
  9. }

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

smalbany
Registered: Jun 8 2010
Posts: 6
I've a flowable form. I'm using the master page to have a header on all pages. The problem is I'd like the header to show up on all pages BUT the first page.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
In this case you will need at least 2 masterpages (one with and one without the header).

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs