Update cookies preferences
Promotic

onPageAction - event of the PmaWebDir object

Description:
The event is triggered after sending parameters and data from the HTML document into the PROMOTIC application, for example after the HTML form is filled in.
Parameters:
pMe(Object) Reference to the PmaWebDir object where the event rises.
pEvent(Object) Reference to an object describing detailed information about the specific event.
pEvent.Method - (String) [for reading] Name of the HTTP method by which the parameters were sent:
"POST" - Sending parameters from the HTML form
"GET" - Sending parameters as a part of the required new page
pEvent.FilePath - (String) [for reading] Relative path to the file that is requested from the Web browser.
pEvent.Params - (String) [for reading] Text string that contains parameters in the URL.
This string has the form, for example "a=13&b=xyz". It means that "a" has the value "13" and "b" has the value "xyz".
It is possible to separate individual values from this string by the Pm.HTTPGetFormValue method.
pEvent.Data - (Variant) [for reading] It contains sent data (the request body content of the HTTP method POST).
The data are either in the form of the string for simple text form or in the form of the PmBuffer object for complex binary form.
The data in the text for have the same form as parameters in the URL, so it can be read by the Pm.HTTPGetFormValue method.
The data in binary form must be processed by the Pm.HttpFormDataParse method.
Note:
The event is triggered after the PmaWeb.onNewRequest event and before creating the answer to the client (before loading and modifying the file pEvent.FilePath and before the PmaWebDir.onPageModify event).
The event is triggered only if the client that sends the data, meets the "WebWrite" permission.
 
The HTML form can send data by the POST method to the server in a simple text form application/x-www-form-urlencoded, e.g. "Name1=Value1&Name2=Value2 ...", where the individual values can then be read by Pm.HTTPGetFormValue.
 
The HTML form can also send the data by the POST method to the server in a complex binary form multipart/form-data, that may contain text values together with binary data and files. The raw data in the form of the PmBuffer object can then be processed by the Pm.HttpFormDataParse method.
 
Caution! In older PROMOTIC versions, the pEvent.Data parameter did not exist. The pEvent.Params parameter then contained either the URL address parameters or the request body.
In order to preserve the compatibility when converting the older applications the first line of the script contains the command for the original behavior.
//#pragma option OldPageAction = 1 (for JavaScript) or
'#pragma option OldPageAction = 1 (for VBScript).
Example1:
Example of sending data from the HTML form (the "POST" method). The HTML form has, for example, the following content:
<html><head>
  <title>HtmlForm example</title>
</head>
<body>
  <form action="main.htm" method="POST">
    value:
    <input type="text" name="V1" value="22"/>
    <input type="submit" value="Send to the server"/>
  </form>
</body>
<html>
 
If the client enters the value, for example, 33 and it sends the form, then the onPageAction event is triggered on the server with the set values:
JavaScriptVBScriptSelect and copy to clipboard

pEvent.FilePath = "main.htm";
pEvent.Method = "POST";
pEvent.Data = "V1=33";
 
In the event, for example, this algorithm can be used:
JavaScriptVBScriptSelect and copy to clipboard

var sV1;
if (pEvent.FilePath == "main.htm")
{
sV1 = Pm.HTTPGetFormValue("V1", pEvent.Data);
// the value "33" is in the sV1 variable ...
}
Example2:
Example of sending parameters as a part of the required new page from another HTML page (the "GET" method). In any HTML page there can be, for example, the reference:
<A href="main.htm?V1=33">Set V1=33</A>
Example of sending parameters as a part of the required new page directly from the address line of the Web browser (the "GET" method). In the Web browser enter, for example:
http://user1/dir/main.htm?V1=33
 
In the event, for example, this algorithm can be used:
JavaScriptVBScriptSelect and copy to clipboard

var sV1;
if (pEvent.FilePath == "main.htm")
{
sV1 = Pm.HTTPGetFormValue("V1", pEvent.Params);
// the value "33" is in the sV1 variable ...
}
Example3:
Parsing the array of maps containing the file data received by upload from a client.
See Preconfiguration "PmaWebDir - Uploading files from Web client to the server".
JavaScriptVBScriptSelect and copy to clipboard

var oData = pEvent.Data;
if (Pm.GetVarType(oData, 1) == "PmBuffer")
{
var aParts = Pm.HttpFormDataParse(oData);
var iPart;
for (iPart = 0; iPart < oData.GetSize(1); iPart++)
{
var mPart = aParts.GetItem(iPart, -1);
Pm.Debug(mPart.Name);
Pm.Debug(mPart.File);
Pm.Debug(mPart.Type);
Pm.Debug(mPart.Value.GetSize());
}
}

History:
Pm9.00.15: New the pEvent.Data parameter.
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.