Inserting code snippets into EGL and JSP files

The Snippets view lets you insert reusable programming objects into your code. The Snippets view contains several pieces of EGL code, as well as code for many other technologies. You can use the snippets provided or add your own to the Snippets view. For more information about using the Snippets view, see Snippets view.

To insert an EGL code snippet into your code, do as follows:

  1. Open the file to which you want to add a snippet.
  2. Open the Snippets view.
    1. Click Window > Show View > Other.
    2. Expand Basic and click Snippets.
    3. Click OK.
  3. In the Snippets view, expand the EGL drawer. This drawer contains the available EGL code snippets.
  4. Use one of these methods to insert a snippet into the file:
    • Click and drag a snippet into the source code.
    • Double-click a snippet to insert that snippet at the current cursor position. You may see a window describing the variables in the snippet. If so, enter values for these variables and then click Insert.
    Note: If the cursor turns into a circle with a strike through it, indicating that the snippet can not be inserted at that point, you may be trying to insert the snippet into the wrong place. Check the snippet's details to find out where it should be inserted in the code.
  5. Change the pre-defined names of functions, variables, and data parts in the snippet as appropriate to your code. Most snippets include comments that explain what names need to be changed.

Following are the snippets available in EGL:

Table 1. Snippets available in EGL
Snippet name Description
setCursorFocus A JavaScriptâ„¢ function that sets the cursor focus to a specified form field on a Web page.
autoRedirect A JavaScript function that tests for the presence of a session variable. If the session variable is not present, it forwards the browser to a different page.
getClickedRowValue An EGL function that retrieves the hyperlinked value of a clicked row in a data table.
databaseUpdate An EGL function that updates a single row of a relational table when passed a record from a PageHandler.

Related concepts
Snippets view

Related tasks
Using the EGL templates with content assist
Setting the focus to a form field
Testing browsers for a session variable
Retrieving the value of a clicked row in a data table
Updating a row in a relational table

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.