2 8 JavaScript and the Script Weblet

LANSA WAM

2.8 JavaScript and the Script Weblet

2.8.1 Can I create my own Script Weblet?

2.8.2 How do I Format inline JavaScript for a Weblet Property?

The script weblet – std_script – is not visualized.

The std_script weblet loads a number of external JavaScript files and initializes a number of JavaScript variables and functions used by the LANSA weblets.  It should be included in the <head> section of all layouts.

The external JavaScript files referenced are a small set of JavaScript files installed on the web server to support WAMs. These scripts are loaded into a subdirectory /script directly under the image directory. If you create your own script weblet, ensure that the scripts included in the shipped std_script weblet are included in your script weblet.

These files are shipped minified (Most whitespace removed). The non-minified versions of these files are also shipped in the same directory.

If you wish to provide your own localized versions of the JavaScript messages, make a copy of std_script_messages.min.js and translate the messages.  Then edit the language specific version of the std_locale weblet and update the lweb_script_messages_file and lweb_script_messages_file_charset variables.

To add your own JavaScript files to a page or layout, Enroll your JavaScript file as a Web Images external resource. Add the external resource to the webroutine or weblet that requires it. The corresponding <script> element will be added at runtime automatically.

Notes:
  • Every layout has a javascript_files property, which is passed to the std_script weblet.  This parameter takes a comma-delimited list of file names (assumed to be relative to the /script directory).
  • From Version 13.0, WAM output is in UTF-8. <script> elements for the javascript_files property didn't have a charset attribute, therefore they were assumed to be in the same character set as the main document. To preserve backwards compatibility, they now have a charset attribute that defaults to "shift_jis" for language JPN and to "iso-8859-1" for all other languages. If you need to nominate a different character set, use the javascript_files_charset property in weblet std_script (you will need to add this parameter to your site layout). A better approach is to register your extra JavaScript files as external resources and include them as such.

     Several of the shipped weblets also include small inline JavaScript functions in the XSL.