Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

3.  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(#frametgt)

...

 Type(*char)

...

 Length(20)

...

     Define Field(#currlang)

...

 Type(*char)

...

 Length(4)

...

 Default(*language)
*

...

 
Group_

...

By Name(#webform)

...

 Fields((

...

#stdrentry *hidden)

...

 (

...

#frametgt *noid)

...

 #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(#frametgt)

...

 To(<your iframe name>)
Change Field(#stdrentry)

...

 To(N)
*

...

 
Request Fields(#webform)

...

 Exit_Key(*no)

...

 Menu_Key(*no)

...

 Prompt_Key(*no)
*

...

 

2.  Replace <your wam name>, <your wam name> and <your iframe 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:

<iframe style     <iframe style="width:600px; height height:400px" name name='<RDML MERGE<RDML MERGE="FRAMETGT">'></iframe>

6.  Save the page as FRAMETGT.

...

9.  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;

      }

...

          
     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>

10. Save the page as SEARCHWAM.

...