2.8.2 How do I Format inline JavaScript for a Weblet Property?
Any weblet property where JavaScript is a valid or expected value will accept an inline JavaScript enclosed in single quotes. The format of the JavaScript is your responsibility.
All inline JavaScript must end with a semicolon (;) For example, 'alert("hello world");'. Note that, because the JavaScript must be enclosed in single quotes (this is done for you in the background), you cannot use a single quote within the code. If you need to do this, consider creating a function in an external JavaScript file and calling it from your inline code.
Most properties that expect JavaScript are executed in response to an event or just prior to performing some action. For example, the presubmit_js property of the std_button weblet is executed just before the form is submitted to the server. This gives you the opportunity to provide some extra processing or to cancel the event/action. To cancel the event/action you must use "return false;"
For example:
if ( confirmWithUser() == false) return false;(where confirmWithUser is a function you have defined in an external JavaScript file)
JavaScript Notes:
1: Do not use return or return true in your inline JavaScript. This has a similar effect to return false in that it stops execution of the LANSA JavaScript but it does not stop the browser from performing its default event handling. This may result in strange and unexpected behavior.
2: The { and } characters have a special meaning in XSLT and cannot be used in a JavaScript property. Doing so will cause strange behavior. If you need to write more complex JavaScript that requires these characters you should create a separate JavaScript function and call it from your property.
3: Previous versions of the documentation advised ending the JavaScript with a double backslash (//) to cancel the default processing. This technique has the same effect as using return and should not be used.