Page History
...
1. Use the provided JavaScript function named HandleWAMEvent().
This This function can be called the same way HandleEvent() function is called now.
2. The parameters are HandleWAMEvent(WAM, Webroutine, TechServ, Form, Target, actionRequest, Partition, Language, optSessionKey, optDebugMode, "ASURNAME", "ASTDRENTRY", ...), a variable number of parameters can be passed for fields, the values of which are to be passed to the Webroutine. It is important to provide a single character prefix before the field name. The prefix is A for Alphanumeric, P for Packed and S for Signed fields, or Q for RDMLX fields. Although this prefix is not required when passing field values to a WAM WEBROUTINE, it is required to access the form field value, as well as being more consistent with HandleWebEvent() JavaScript function semantics.
The parameters of HandleWAMEvent are:
WAM | The name of the target WAM. |
|---|---|
Webroutine | The name of the target WEBROUTINE. |
TechServ | The Technology Service to use, can be null for default LANSA XHTML Technology Service. |
Form | The form HTML object to get field values for submit from, e.g. document.MYFORM for a form with "MYFORM" name, can be null for default LANSA form. |
Target | The target iframe, frame or window where the result of navigation will be displayed, null to navigate to a new page. |
actionRequest | If left null, is the default "cgi-bin/lansaweb" action request. |
Partition | The partition to execute the WAM from. |
Language | The language under which the WAM will execute. |
optSessionKey | Can optionally pass the session key, if the SessionKeyMethod is URL, otherwise null. |
optDebugMode | Can pass the debug url keyword to allow debugging of the WAM, otherwise null. |
...
1. Create a function and paste this code:
...
Function Options(*
...
DIRECT *webevent)
*
...
Define Field(#searchwam)
...
Type(*char)
...
Length(1)
...
Define Field(#wamname)
...
Type(*char)
...
Length(9)
...
Define Field(#webrname)
...
Type(*char)
...
Length(20)
...
Define Field(#techserv)
...
Type(*char)
...
Length(21)
...
Define Field(#currlang)
...
Type(*char)
...
Length(4)
...
Default(*language)
*
...
Group_
...
By Name(#webform)
...
Fields((
...
#stdrentry *hidden)
...
#surname #searchwam (#currlang *hidden)
...
(
...
#partition *hidden)
...
(
...
#wamname *hidden)
...
(
...
#webrname *hidden)
...
(
...
#techserv *hidden))
*
...
Change Field(#wamname)
...
To(<your wam name>)
Change Field(#webrname)
...
To(<your wam webroutine name>)
Change Field(#stdrentry)
...
To(N)
*
...
Request Fields(#webform)
...
Exit_Key(*no)
...
Menu_Key(*no)
...
Prompt_Key(*no)
*
...
2. Replace <your wam name> and <your webroutine name> with the appropriate names.
Note Note that the WAM must exist in the same partition and will execute in the same language using the default LANSA:XHTML technology service. Otherwise, change the values of fields #techserv, #currlang and #partition accordingly.
...
5. Create a new page and paste this code:
...
<button onclick="return HandleWAMEvent('
...
<RDML MERGE="WAMNAME">', '
...
<RDML MERGE="WEBRNAME">',
...
'
...
<RDML MERGE="TECHSERV">',
...
null,
...
'
...
<RDML MERGE="TARGET">',
...
null,
...
'
...
<RDML MERGE="PARTITION">',
...
'
...
<RDML MERGE="CURRLANG">',
...
null,
...
null,
...
'ASURNAME',
...
'ASTDRENTRY'
...
)">Search</button>
...
<script type="text/javascript">
//<![CDATA[
function CreateTempForm(ownerDoc)
{
...
var oTempForm = ownerDoc.createElement("form");
...
if (oTempForm != null)
{
...
{
if (typeof oTempForm.setAttribute === "function")
{
...
{
oTempForm.setAttribute("method", "post");
}
else
{
...
}
else
{
oTempForm = ownerDoc.createElement("<form method=\"post\"></form>");
}
}
return oTempForm;
}
...
}
}
return oTempForm;
}
function HandleWAMEvent(WAM, WebRoutine, techServ, Form, Target, actionRequest, Partition, Language, optSessionKey, optDebugMode /*, field1, field2, etc...*/)
{
...
if (Form == null)
{
...
{
Form = document.LANSA;
}
if (techServ == null)
{
...
}
if (techServ == null)
{
techServ = "LANSA:XHTML";
}
...
}
var oTempForm = CreateTempForm(Form.ownerDocument);
...
if (oTempForm != null)
{
...
{
Form.ownerDocument.body.appendChild(oTempForm);
...
var argLen = arguments.length;
...
if (argLen > 10)
{
...
{
for (var index = 10; index < argLen; index++)
{
...
{
var fieldNameWithPrefix = arguments[index];
...
var fieldName = fieldNameWithPrefix.substr(1, fieldNameWithPrefix.length - 1);
...
for (var ind = fieldNameWithPrefix.length; ind < 10; ind++)
{
fieldNameWithPrefix += " ";
}
...
{
fieldNameWithPrefix += " ";
}
var fieldValue = Form.elements[fieldNameWithPrefix].value;
...
InsertHidden(oTempForm, fieldName, fieldValue);
}
}
// Add STDANCHOR if available
...
}
}
// Add STDANCHOR if available
var anchorField = Form.elements["ASTDANCHOR"];
...
if (anchorField != null)
{
...
{
InsertHidden(oTempForm, "STDANCHOR", anchorField.value);
}
...
}
var prevAction = oTempForm.action;
...
var prevTarget = oTempForm.target;
...
var action = "";
...
if (actionRequest == null || actionRequest.length <= 0)
{
...
{
actionRequest = "/cgi-bin/lansaweb";
}
...
}
action += actionRequest + "?wam=" + WAM + "&webrtn=" + WebRoutine + "&ml=" + techServ + "&part=" + Partition + "&lang=" + Language;
...
if (optDebugMode != null && optDebugMode.length > 0)
{
...
{
action += "&debug=" + optDebugMode;
}
if (optSessionKey != null)
{
...
}
if (optSessionKey != null)
{
action += "&sid=" + optSessionKey;
}
...
}
oTempForm.action = action;
...
if (Target != null)
{
...
{
oTempForm.target = Target;
}
...
}
oTempForm.submit();
...
setTimeout(function() {
...
oTempForm.action = prevAction;
...
oTempForm.target = prevTarget;
...
oTempForm.parentNode.removeChild(oTempForm);
...
}, 100);
}
...
}
return false;
}
function InsertHidden(Form, FieldName, FieldValue)
{
...
if (Form == null)
{
return;
}
...
{
return;
}
var field = Form.elements[FieldName];
...
if (field == null)
{
...
{
var elem = Form.document.createElement("input");
...
if (elem != null)
{
...
{
elem.setAttribute("type", "hidden");
...
elem.setAttribute("name", FieldName);
...
elem.setAttribute("value", FieldValue);
...
Form.appendChild(elem);
}
}
else
{
field.value = FieldValue;
}
}
}
}
else
{
field.value = FieldValue;
}
}
//]]>
</script>
6. Save the page as SEARCHWAM.
...