Step 5 Use Hidden Fields in Function

LANSA Web Functions

Step 5. Use Hidden Fields in Function

In this step, you will add a hidden field to the REQUEST panel in iiiFN05 and assign a Web Page component to the field. This component will contain the HTML for displaying the CALENDAR button which you manually added to the HTML. Using this technique, the calendar button will automatically be included in the page without manually editing the HTML.

1.  In the LANSA Editor, edit the RDML for your iiiFN05 function. Add the following RDML line to define a field in the function:

DEFINE FIELD(#iiiCOMP) TYPE(*CHAR) LENGTH(1)

 

     The characteristics of this field are not important. The field is simply a dummy hidden field which can be used for component substitution.

2.  Modify the REQUEST statement so that it appears as follows:

REQUEST   FIELDS((#DEPTMENT)( #STD_DATE)(#iiiCOMP *HIDDEN)) DESIGN(*DOWN) IDENTIFY(*DESC) MENU_KEY(*NO) EXIT_KEY(*NO) USER_KEYS((01 SEARCH))

 

 

3.  Save and exit the RDML function but do NOT compile the function yet.

4.  Create a new HTML page by using the File menu category and selecting the New option.

5.   Delete the default HTML which appears and enter the following HTML into the page:

  

<a href="javascript:CallCalendar()"><img src="/IMAGES/TB_CAL.GIF" alt="Calendar" border="0" width="70" height="21" hspace="0" vspace="0" align="left" /></a>

 

 

6.  Save the file as iiiCOMP with description Hidden Field Component for Calendar.

7.  Use the Components menu category and select the Maintain option. A list of all components in the partition will be displayed. Press the Add button to define a new component as follows:

Name:

iiiCOMP

Type:

PAGE

 

  

     Press the Continue button and then enter the following details:

Description:

Calendar Button

Page:

iiiCOMP

Mode:

OUTPUT

 

  

     The mode of this component is very important. Because the field is hidden in the REQUEST statement, this component must be an OUTPUT component.

8.  Now that the component has been created, you can submit the iiiFN05 function for recompile. Remember, compiling the function will replace your modified HTML with a new version.

9.   Check that the compile was successful and then test your function. You should see the Calendar button at the top of your function. Notice that you did not have to edit the HTML. The iiiCOMP was automatically embedded by LANSA. You may wish to review the HTML page for function iiiFN05 to review how the hidden field was used in the HTML page.