pgExecuteRemote

Help for using specific functions

pgExecuteRemote

Postby Andy » Thu Dec 13, 2018 11:33 am

Hi Clifton, I am using gotoURL to launch a rich text editor with a field on the page as the target. I need to pull back several kilobytes of text from the editor and also send the text to populate the editor at a later time. My question is what is the best way to pull back the text. I could use pgExecuteRemote on my page to call a function that provides the text as a return value. Or I could call pgExecuteRemote in the editor to populate a hidden field on the page with tbObjSet, and then transfer the text to my global ToolBook variable. The second way seems more reliable to me but I don't really know. What would be your recommendation? Thanks, Andy
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: pgExecuteRemote

Postby Clifton » Thu Dec 13, 2018 1:13 pm

It seems either approach in your post should work.
Another approach IF the main window and editor are running from the same server, which they probably are:
  1. You could just use pgExecuteRemote to run pgTBObjSet() to send a user event to the main window with the data as the [value] parameter.
  2. The same can be done from the main window back to the editor.
  3. This approach eliminates the need for hidden fields and variables. Global variables are not good places to store data is raw form as they can be manipulated easily by prying eyes.
Example:
    In editor window when user has entered requested information in a field called "myInfo" and now the information needs to be sent to the main window to a field called "userInfo":
    pgExecuteRemote( "main", "tbfunction_pgTBObjSet", [ "userInfo", "user", data ], false );

    To send information to populate the field "myInfo" in the editor window with "userInfo" in main window:
    pgExecuteRemote( [name of target window], "tbfunction_pgTBObjSet", [ "myInfo", "user", data ], false );

    The user event in each window would parse the data an needed to achieve the desired results.
    NOTE: I using an array to send the parameters to pgTBObjSet(). This is really easy in an XML file as you just enter it very similar to what I've done above. To do this Actions system, you would need to define a temporary array to hold the parameters and send the Actions array instead.
Another approach to this may be to use session cookies created with createCookie(). This is no data size restrictions when using session cookies and they are automatically deleted when the browser window/tab is closed.

So in conclusion, rather than saying one way is better than another, you have multiple ways to accomplish the same thing and depending on you application, you can choose which one is most efficient.
 
Clifton
Site Admin
 
Posts: 731
Joined: Tue Jan 14, 2014 1:04 am

Re: pgExecuteRemote

Postby Andy » Thu Dec 13, 2018 2:51 pm

What a great explanation of the alternatives! I had not even considered session storage, but it's simple and modular and will be perfect for this situation. Thanks so much!
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: pgExecuteRemote

Postby Clifton » Thu Dec 13, 2018 3:17 pm

I would also recommend that you consider using the PowerPac v15 beta. Though not essential, it contains some enhancements and bug fixes that may benefit you moving forward with your project. It is called a beta, but the vast majority of this new version is production-ready and I've already adopted it in my in-house projects as the preferred version.

https://pgsoftwaretools.com/toolbook/phpLibrary/attachments/betaVersion/Install_PowerPac_v15beta.zip
 
Clifton
Site Admin
 
Posts: 731
Joined: Tue Jan 14, 2014 1:04 am


Return to Function Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron