10 Replies Latest reply on Sep 27, 2011 11:31 AM by pguerett

    Error with JavaScript on XDP form rendered as HTML

    NateAtREIS1 Level 1

      I have saved a form as an XDP and am rendering it as HTML with LiveCycle Forms Server ES. When I click on certain form buttons that cause JavaScript code to fire, I get the following error:

       

      this._peer is undefined

       

      I've seen this error posted in a few Adobe forum posts without answers. Any ideas?

       

      - Nate

        • 1. Re: Error with JavaScript on XDP form rendered as HTML
          pguerett Level 6

          The buttons that are generating the errors are they buttons that you have jkavascript behind or are they submit buttons?

           

          Paul

          • 2. Re: Error with JavaScript on XDP form rendered as HTML
            NateAtREIS1 Level 1

            They are buttons that I have JS behind. The submit buttons work fine.

            • 3. Re: Error with JavaScript on XDP form rendered as HTML
              pguerett Level 6

              Can you post the code that you have behind those buttons? Is it set to run at Client or at Server?

               

              Paul

              • 4. Re: Error with JavaScript on XDP form rendered as HTML
                NateAtREIS1 Level 1

                Here's a snippet of the button that runs the JS. It's really long, so I cut out most of the JS. I can post the whole thing if you want. It is set to run at the client.

                 

                <input class="fsc33 fsc21 fsc22 fsc2" id="NButton2_0" name="Button2[0]" onclick="return this._peer._clickfunc(***JS REMOVED FROM POST TO SAVE SPACE***)" type="button" value="Insert Clause" />

                • 5. Re: Error with JavaScript on XDP form rendered as HTML
                  pguerett Level 6

                  I was looking for the code that you added to the button ……in Designer what type of button is it and what do you expect that button to do when it is clicked?

                   

                  Paul

                  • 6. Re: Error with JavaScript on XDP form rendered as HTML
                    NateAtREIS1 Level 1

                    It is a regular button that fires code that does a popup dialog box. It works fine when the form is rendered as a PDF; I get the "this._peer is undefined" error when I render it as HTML and try to run the code. Here's the code:

                     

                    var insert_clauses =

                    {

                     

                    result:"cancel",

                    DoDialog: function(){return app.execDialog(this);},

                    strpop1:"",

                    SetListSel:function(list,path){if(path.length == 0) return;

                    eval("list[\""+ ((typeof path.join != "function")?path:path.join("\"][\"")) + "\"] = 1")},

                    GetListSel:function(oLstRslts,path){

                       for(var item in oLstRslts){

                          if( ((typeof oLstRslts[item]=="number")&&(oLstRslts[item]>0))

                             || this.GetListSel(oLstRslts[item],path) )

                           {path.push(item);return true;}

                       }

                       return false;

                    },

                    initialize: function(dialog)

                    {

                    //this.xfa.form.Ultra_Form.Page1.clauses.rawValue;

                    //var listpop1 = {"Clause1": -1,"Clause2": -2}

                     

                    var listpop1 = {};   

                    //listpop1["Select a clause to insert"] = 1;

                     

                    //xfa.resolveNode("xfa.datasets.data.Ultra_Form.Page1.clauses").value

                    var arrClauses = xfa.resolveNode("xfa.datasets.data.Ultra_Form.Page1.clauses").value.split("||"); //

                     

                    var num=0;

                    while (num < (arrClauses.length))

                    {

                      var test = arrClauses[num];

                      listpop1[test] = -num;

                      num+=1;

                    }

                    //dialog.load({"pop1": listpop1});

                     

                    this.SetListSel(listpop1, this.strpop1);

                    var dlgInit =

                    {

                    "pop1": listpop1,

                    };

                    dialog.load(dlgInit);

                    },

                     

                    commit: function(dialog)

                    {

                    var oRslt = dialog.store();

                    var path = new Array();

                    this.strpop1 = (this.GetListSel(oRslt["pop1"],path))?path.reverse():"";

                    },

                     

                    description:

                    {

                    name: "Insert Clauses",

                    elements:

                    [

                    {

                    type: "view",

                    width: 757,

                    height: 86,

                    elements:

                    [

                    {

                    type: "view",

                    width: 735,

                    height: 43,

                    char_height: 10,

                    elements:

                    [

                    {

                    type: "popup",

                    item_id: "pop1",

                    name: "clauses",

                    width: 717,

                    height: 23,

                    char_width: 8,

                    },

                    ]

                    },

                    {

                    type: "ok_cancel",

                    },

                    ]

                    },

                    ]

                    }

                    };

                     

                    // Example Code

                    insert_clauses.strpop1 = "";

                    if("ok" == insert_clauses.DoDialog())

                    {

                        if(this.xfa.form.Ultra_Form.Page1.Seller_Name.rawValue == null)

                        {

                            cur_val = "";

                        }

                        else

                        {

                            cur_val = this.xfa.form.Ultra_Form.Page1.Seller_Name.rawValue;

                        }

                     

                        new_val = cur_val + insert_clauses.strpop1;

                        this.xfa.form.Ultra_Form.Page1.Seller_Name.rawValue = new_val;

                        xfa.host.setFocus("this.xfa.form.Ultra_Form.Page1.Seller_Name.somExpression");

                        app.setTimeOut("xfa.host.setFocus('" + this.xfa.form.Ultra_Form.Page1.Seller_Name.somExpression + "');", 10);

                     

                    }

                    • 7. Re: Error with JavaScript on XDP form rendered as HTML
                      NateAtREIS1 Level 1

                      The JS I put on this link produces the same error:

                       

                      <a href="#" tabindex="4" onclick="return this._peer._clickfunc(&quot;\nxfa.host.print(1, \&quot;0\&quot;, (xfa.host.numPages \-1).toString(), 0, 0, 0, 0, 0);\n&quot;)">Print</a>

                      • 8. Re: Error with JavaScript on XDP form rendered as HTML
                        pguerett Level 6

                        That’s your issue ….the app object is not known when you render as an HTML page. You may want to change this to an xfa.host.messageBox or use a native javascript dialog box (remember that you are running in a browser as HTML).

                         

                        Paul

                        • 9. Re: Error with JavaScript on XDP form rendered as HTML
                          NateAtREIS1 Level 1

                          Hmm....doing a test with xfa.host.messageBox didn't seem to work either:

                           

                          <input class="fsc20 fsc21 fsc22 fsc2" id="NButton3_0" name="Button3[0]" onclick="return this._peer._clickfunc(&quot;\nxfa.host.messageBox(\&quot;yeah this worked\&quot;);\n&quot;)" tabindex="276" type="button" value="Button" />

                           

                          I still get the "this._peer is undefined" error. It seems like any time I try to use onclick="return this._peer._clickfunc()" I get this error.

                          • 10. Re: Error with JavaScript on XDP form rendered as HTML
                            pguerett Level 6

                            Can you email me your XDP and I will try it here.

                             

                            Send it to LiveCycle8@gmail.com<mailto:LiveCycle8@gmail.com>

                             

                            Paul