4 Replies Latest reply on Aug 16, 2010 11:15 AM by pguerett

    How do I set the value of a dynamic row text field


      I have a repeated row form which contains a button and multiple text fields.  There is a text field (Input Data Field) further up with some information I want to place in the table and multiple buttons that I want to read the value of and set to the table.  I apologize there are multiple questions I have and I am using pseudocode to describe it.


      Top form looks like




      | ButtonX1 | ButtonY1 | DescriptionX1 (read only Text Field)


      | ButtonXn | ButtonY1 | DescriptionXn


      OutputRow looks like


      | ButtonOutput | OutputField1 | OutputField2 | OutputField3 |


      So I would like it to do




      OutputTable.OutputRow.addInstance(true)  //this works - everything else I have questions on


      OutputTable.OutputRow.OutputField1.rawValue = DescriptionX1.rawValue


      Question 1

      How do I address the location in each table to set a value


      Question 2

      How do I get the value of the description field in the same table and row as the button


      I would like to say something to the effect of  OutputTable.OutputRow[??].OutputField1.rawValue = this.parent.DescriptionX




      OutputTable.OutputRow.OutputField2 = InputField.rawValue


        Same question as above - how do I specify a dynamic row - is this the proper syntax for getting the value from the input field?



      OutputTable.OutputRow.OutputField3 = this.ButtonLabel


      Question 3

        How can I get the value of the button's label to set in the field

        There should be very many of these buttons and buttons will be added - I would prefer to set the value based on the button's label to make the value easier - not requiring changing the code



      Question 4 - unrelated to those above.

      Is it possible to build the first table

      | ButtonX | ButtonY | Description |

      from an XML File.  I have seen examples of how to build if it is just data, but can the XML be pushed into a form with code to do the above actions?

        • 1. Re: How do I set the value of a dynamic row text field
          pguerett Level 6

          Each object in a form must have a unique name. I doing so it is not neccessarily the name but the path or SomExpression associated with that object that must be unique. In your case you have a Table.Row.object configuration. The Row is the part that is repeating so to give each object a unique name an instance number is placed on the repeating part. So objects in the 1st row woudl be Table.Row[0].object...objects in the second row woudl be Table.Row[1].object etc .....You can see this by adding a debug instruction on the Enter event of the description field. Put the code app.alert(this.somExpression) and when you enter the field you will see what the somExpression is. Do this for a few rows and you will see the pattern (don't forget to remove the debug code from the enter event). Now you know what you have to use to address the fields. If no instance is given it is assumed to be 0 ..that is why only the 1st row is being affected.



          So now to answer your questions:


          Question1: The square bracket notation is an issue for javascript (this is the notation for an array) so we have to use a different means of addressing the field to include the instance number. So to address the Description in the 3rd row we woudl use:


          xfa.resolveNode("Table.Row[2].Description").rawValue = "This is my new description";


          Note that the instance number is 2 for the 3rd row because the instance numbers are 0 based.


          Question2. The resolveNode notation allows you to pass a string so you can also concatinate expressions to make the string. If you are writing code on a button in the same row you can get the instance that you are on by using the expression this.parent.index. The "this" portion refers to the current object (the button) and the parent.index gets you th eindex of the Buttons parent. If the button is embedded deeper in a hierarchy then you can continue to add parent indicators until you get back to the node that you want. So rewriting your expression from Q1 it woudl be:


          xfa.resolveNode("Table.Row[" + this.parent.index + "].Description").rawValue = "This is my new description";


          Question3: The buttons caption can be retrieved by using ButtonName.caption.value.text.value


          Question4: When you say build from an XML file. What are you expecting to come from the XML file? The caption that goes on the button? Typically the XML file carries data (not to say that it cannot carry other things). Just need a bit of clarification on this one first.


          Hope that helps


          1 person found this helpful
          • 2. Re: How do I set the value of a dynamic row text field
            davidpath Level 1

            Great, thanks for the answers. I have most of this working now


            Event code - OnClick - ButtonX1



            OutputTable.resolveNode("OutputRow[1]").OutputField1 .rawValue = this.parent.DescriptionX1.rawValue
            OutputTable.resolveNode("OutputRow[1]").OutputField2 .rawValue = this.resolveNode("caption.value.#text").value
            OutputTable.resolveNode("OutputRow[1]").OutputField3 .rawValue = InputField.rawValue



            InputField (value set to "TestValue")

            | ButtonX1 (caption "TESTCAPTION") | ButtonX2 (caption "TESTCAPTION2") | "Description of item"


            leads to


            OutputTable Row 0 | Some value | Some Value | Some Value

            OutputTable Row 1 | Description of item | TESTCAPTION | TestValue


            Question 2 continued

            The button is in one table and the result is in another table.  I need to resolve the last added instance of the output table.

            How do I know what the last instance that was added is?  Is there anyway besides iterating through all of the values?  What would I search for if I need to iterate?

            The above code would always sets the second row's data.


            Question 4


            Exactly - the xml would contain captions that would go on the buttons.  I would to keep it simple but have something like




                <Description>Description Field</Description>



            The items on the menu will change often and updating the pdf everytime is difficult.  I suppose I could hard code the buttons and xml the description at the worst case?  I would prefer to be able to fill the whole table as the captions may prefer to be different

            • 3. Re: How do I set the value of a dynamic row text field
              davidpath Level 1

              I think I figured out question 2 continued

              OutputTable.resolveNode("OutputRow[" + OutputTable.OutputRowRow.instanceManager.count-1 + "]").OutputField3 .rawValue = InputField.rawValue


              Is there a problem with doing it that way?

              • 4. Re: How do I set the value of a dynamic row text field
                pguerett Level 6

                Glad you figured it out ...nothing wrong with doing it that way.


                Normally XML contains data and not captions so by default these xml files are bouond to the rawValue property. You can turn on dynamic binding and other properties of the object will become bindable(they appear as links) in the UI. If you click on the link for caption a wizard comes up allowing you to  bind to the appropriate node in the XML.