Summary

LANSA Web Functions

Summary

Important Observations

  • There are many techniques for linking or calling functions. This exercise showed two different examples. The first example used the existing HandleEvent JavaScript function used in LANSA for the Web. In order to pass parameters to the called function, the <process>_HIDDEN fields were used.
  • JavaScript requires that a field be on the page in order to change its value.  The fields iiiDEPTWK and iiiSECTWK were added to our _HIDDEN for this purpose.
  • When you use an <A HREF> to execute a function,  no data is exchanged to the called WEBEVENT function. (The <A HREF> starts a new Web job, as it is calling a new function.) It is exactly the same as calling a function for the first time from a new browser window. The function parameters (funcparms) had to be used to overcome this limitation. In this example, the Employee Number was passed and the called function used this value to fetch the required data.
  • In the image example, the image uses the default image directory of your Data/Application Server.  You could place these images in any directory and simply add the directory to either the component or the field where the image value is stored in the file.
  • When you execute a function from the browser command line, you must pass the parameters you wish the function to use.  Parameters are not passed automatically. You added the iiiLOGIN parameter as a funcparm so that the STDHEADER displayed the proper component.
  • If you wish to use the iiiLOGIN component, you must use the iiiLOGIN field somewhere in the function as well as passing the parameter to the function.  In Step 8, you included a GROUP_BY statement including iiiLOGIN.  You could also put the field in a second request or an IF statement that does nothing. If iiiLOGIN is not defined somewhere in the function, the value cannot be used in the STDHEADER.

Tips & Techniques

  • Always create a working field if there is a possibility of more than one function using the field.  We could have used the DEPTMENT and SECTION fields, however they will likely be required by other functions, and if the values are hidden this could cause some problems.  These problems are avoided by creating the temporary holding fields.  A good Web site layout will ensure that you know where this needs to be done.
  • JavaScript can be difficult to debug.  There are free or shared software programs available that can make this job easier.
  • Creating a component style button is one way of including a link in a browse list.  You can also use images or text as links.
  • Using HandleEvent is one way of creating a link inside an LANSA function.  Another technique is to use the <A HREF> and to add your funcparms to this line, using <RDML MERGE="<fieldname>"> .
  • In this example, the employee image file names were placed in the PHONEBUS field. If you have an existing database, you can attempt to use an existing field, however, a better technique is to create a parallel file for storing the Web related data. For example, you could create a PLSMT2 file with the same key (EMPNO) but with fields for the images, email addresses, etc.
  • If possible, avoid using <A HREF> tags to call separate WEBEVENT functions, as it does not pass any hidden values with it.  Instead, modify the HandleEvent JavaScript or review the example given in the online documentation about passing parameters in LANSA for the Web.
  • In this example, a new window was opened when using the <A HREF> to call the next function. This is a good technique as it emphasizes the fact that there is no data being passed.

What I Should Know

  • How to add a link to a browse list.
  • How to create process-specific JavaScript to be used with the DEFAULT_SCRIPT.
  • How to pass function parameters within a LANSA function.
  • How to build a browse list using the parameters passed from another function.
  • How to add an image to a browse list using a page component.
  • How to pass function parameters to a LANSA function using funcparms.