6 Replies Latest reply on May 18, 2010 7:11 AM by BKD2012

    trustedFunction

    BKD2012

      Hi,

       

      I'm trying to add an app.launchURL to each Bookmark in the setAction bookmark method.

       

      app.launchURL needs security privileges, then I have created a trustedFunction for that.

       

      I'm using a bucle to assign the URL with differents varibles values for each Bookmark.

       

      The Code in the web:

       

      var bkm = this.bookmarkRoot;

      var p = "";

      for( k=0; k < bkm.children.length; k++){

       

          p = "http://localhost/directory/tPDF.php?p="+k;

       

              app.alert({
               cMsg: "bookmark: "+bkm.children[k].name+" trustedlURL("+p+")",
               cTitle: "Testing"
               });

       

              bkm.children[k].setAction("trustedlURL(p);");

       

       

      }//end for

       

       

      This is the function at the app folder-level Javascript file.

       

      trustedlURL = app.trustedFunction( function (value)
              {
              // Additional code may appear above

       

          app.alert({
              cMsg: "Value: "+value,
              cTitle: "Zone"
              });       
         
              app.beginPriv(); // Explicitly raise privilege
              app.launchURL(value);
              app.endPriv();
              // Additional code may appear below.
              });

       

      The Bookmarknames are:

       

      Page 1

      Page 2

      Page 3

       

      When I click a bookmark the script should launch a different URL like

       

      http://localhost/directory/tPDF.php?p=0 if I click the Page 1 Bookmark name.

      http://localhost/directory/tPDF.php?p=1 if I click the Page 2 Bookmark  name.

      http://localhost/directory/tPDF.php?p=2 if I click the Page 3 Bookmark  name.

       

      But I'm getting a strange behavior in this simple script:

       

      The bookmarks always are sending the same URL.

      http://localhost/directory/tPDF.php?p=2 if I click any Bookmark  name.

       

      But the alert message in the web:

       

              app.alert({
               cMsg: "bookmark:  "+bkm.children[k].name+" trustedlURL("+p+")",
               cTitle:  "Testing"
               });

       

      the alert on the web is showing these values correctly

       

      bookmark: Page 1 trustedlURL(0)

      bookmark: Page 2 trustedlURL(1)

      bookmark: Page 3 trustedlURL(2)

       

       

      How is it posible the variable named "value" at the app folder-level script is always the same, the last p value used in the bucle, if the web script is changing value of variable "p" correctly.

      "p" at the app folder-level script is always receiving the same value in the app.alert of the trustedFunction

       

      http://localhost/directory/tPDF.php?p=2

       

      and the URL launched when I click any bookmark is

       

      http://localhost/directory/tPDF.php?p=2

       

      instead of

      http://localhost/directory/tPDF.php?p=0

      or

      http://localhost/directory/tPDF.php?p=1

      or

      http://localhost/directory/tPDF.php?p=2

       

      I don't understand this behavior.

       

      Any suggestions.