Using a Dynamic Multiselect Drop-Down List

How to:

You can add a dynamic multiselect drop-down list whose values are populated by field values retrieved live from a data source. The data source is allocated dynamically with no fixed maximum record length.

Procedure: How to Add a Dynamic Multiselect Drop-Down List

This procedure uses the Dialogue Manager command –HTMLFORM to populate a drop-down list with values from a data source. Use this technique when selection values change frequently, to ensure that you always derive a list of current valid values.

For details on -HTMLFORM, see Designing an HTML Page for Report Display.

  1. Create a procedure that populates a drop-down list:
    1. Required: Allocate a text file that will contain the dynamic values.

      For example, on Windows, the command is

      FILEDEF textfile DISK APP/textfile.TXT

      where:

      textfile

      Is the name of the file that contains the values.

      APP

      Is the name of the application, under APPROOT, that contains the physical file.

      See Defining and Allocating WebFOCUS Files for details on platform-specific commands.

    2. Include a DEFINE command to create a temporary field that identifies the values.
    3. Include the following command to save the values to the allocated file.
      ON TABLE HOLD FORMAT ALPHA as textfile

      where:

      textfile

      Is the name of the file. The name can be from 1 to 8 characters.

    4. Include the following command to send the report output to the launch page that displays the values.
      -HTMLFORM valuespg

      where:

      valuespg

      Is the name of the launch page.

  2. Create the launch page. Use a comment to indicate where the values display
    !IBI.FIL.textfile;

    or

    <!--WEBFOCUS TABLE textfile-->

    where:

    textfile

    Is the name of the file that contains the values.

    Note: The HTML comment line must be closed with the ---> characters or a single > character and should not have any other HTML tags within it.

    Note that the text file is allocated dynamically in memory and has no fixed length limit.

    The Reporting Server must be able to locate the launch page using APP PATH or EDAPATH. See Choosing Search Path Logic for details on search paths.

  3. Create a procedure that accepts multiple values to generate a dynamic report.

Example: Adding a Dynamic Multiselect Drop-Down List

This example runs on WebFOCUS for Windows. If you are using another platform, substitute the appropriate platform-specific command for the FILEDEF command. For information on the FILEDEF command and where to store the files created in this example, see Defining and Allocating WebFOCUS Files.

  1. Create a procedure named DYNAMMUL, which populates a drop-down list from the field COUNTRY in the data source SHORT.

    Procedure: DYNAMMUL.FEX

    FILEDEF DYNAMLST DISK BASEAPP/DYNAMLST.TXT
    DEFINE FILE SHORT
    OPTCOUNTRY/A40 = '<option>'|COUNTRY;
    END
    TABLE FILE SHORT
    SUM OPTCOUNTRY
    BY COUNTRY NOPRINT
    ON TABLE HOLD FORMAT ALPHA AS DYNAMLST
    END
    -RUN
    -HTMLFORM DYNAMIC2
    -RUN
  2. Create a launch page named DYNAMIC2.HTM. The Reporting Server must be able to locate the page in APP PATH or EDAPATH. See WebFOCUS Application Logic for details on search paths.

    The sample launch page uses the Servlet.

    Launch Page: DYNAMIC2.HTM

    <HTML>
    <TITLE> DYNAMIC DROP-DOWN LIST REPORT </TITLE>
    <H4> PROJECTED RETURN BY COUNTRY </H4>
    <FORM ACTION="/ibi_apps/WFServlet" METHOD="GET">
    <INPUT TYPE="HIDDEN" NAME="IBIF_ex" VALUE="MULRPT">
    <SELECT NAME="COUNTRY" SIZE="3" MULTIPLE>
    <!--WEBFOCUS TABLE DYNAMLST-->
    </SELECT>
    <BR><BR><INPUT TYPE="SUBMIT" VALUE="RUN REPORT!"></FORM>
    </BODY>
    </HTML>

    Note: The HTML comment line must be closed with the ---> characters or a single > character and should not have any other HTML tags within it.

  3. Create a procedure named MULRPT, which displays projected returns for a selected country or countries. (If no countries are selected, projected returns for all countries in the data source will be displayed.)

    Procedure: MULRPT.FEX

    -SET &COUNTER=1;
    TABLE FILE SHORT
    SUM PROJECTED_RETURN
    BY COUNTRY
    -IF &COUNTRY.EXISTS THEN GOTO LOOP1 ELSE GOTO DONE;
    -LOOP1
    WHERE COUNTRY EQ '&COUNTRY'
    -IF &COUNTRY0.EXISTS NE 1 THEN GOTO OUTLOOP;
    -REPEAT OUTLOOP FOR &COUNTER FROM 2 TO &COUNTRY0;
    OR '&COUNTRY.&COUNTER'
    -OUTLOOP
    -DONE
    ON TABLE SET PAGE-NUM OFF
    ON TABLE SET STYLE *
    TYPE=REPORT, GRID=OFF,$
    ENDSTYLE
    END

    Note: At run time, &COUNTRY0 contains the number of countries selected in the multiselect drop-down list. For example, if three countries are selected, &COUNTRY0 is set to 3, &COUNTRY and &COUNTRY1 are set to the first country selected, &COUNTRY2 is set to the second country selected, and &COUNTRY3 is set to the third country selected.

    This example is for WebFOCUS environment with the Amper Auto-prompting feature not enabled (WF Client config variable IBIF_wfdescribe=OFF). For more information on the configuration parameter IBIF_wfdescribe, see the TIBCO WebFOCUS® Security and Administration manual.

    If environment has the Amper Auto-prompting feature enabled, the following parameter can be added to the form to turn off the Amper Auto-prompting feature for the request being submitted from this form.

    <INPUT TYPE="HIDDEN" NAME="IBIF_wfdescribe" VALUE="OFF">
    add the above line to example file DYNAMIC2.HTM after line 
    <FORM ACTION="/ibi_apps/WFServlet" METHOD="GET"> 
  4. Run the procedure DYNAMMUL. You can also use JavaScript to run a procedure when a launch page opens.

    A page similar to the following displays:



  5. Select CANADA, HONG KONG, and MEXICO. Click RUN REPORT! to receive the report: