Adding a WebFOCUS Report to Your Application
In the previous section, you added a welcome screen
to your application with four menu options. One of these options,
Show all Fans, does not do anything. You are going to add another
form to your application that displays the results of a WebFOCUS report.
This report procedure, fanrpt.fex, is one of the sample files that
came with WebFOCUS.
You can use the results of a WebFOCUS
procedure in your application in one of two ways:
- You can return the formatted results
of the report into a one-column stack, which you then display using
an HTML Object.
The stack can be named
anything, but the column in the report must be named HTML.
The
report must have the line:
ON TABLE PCHOLD FORMAT HTMTABLE
x
Procedure: How to Add a WebFOCUS Report to Your Application
-
In the
Explorer, open the Procedures folder.
-
Make
sure that Display all files is turned on. Either in the View menu, or
by clicking the button on the Exploring toolbar.
-
Right-click fanrpt.fex and
click Add to project.
x
Procedure: How to Define a Stack to Receive WebFOCUS Report Output
-
Create
a new data source stack in the Start procedure by right-clicking Start and
clicking New data source stack.
-
Give
your stack the name HtmlStack.
Up until this point, you have created data source stacks
based on the fields of a data source. For this stack, you will create
a custom column.
-
Double-click New
variable to open the Computed Stack Column dialog box.
-
Give
your column the name HTML (if you name it anything else, the report
will not work).
-
Click
the button
to open the Type Wizard. The Type Wizard helps you assign a data
type to your new column.
-
Leave
the Built-in Type and Simple choices, but change Integer to Alphanumeric
and the size to 250.
Notice
at the bottom of the dialog box, that the Type Wizard uses an abbreviation of
A250 to represent your data type choice.
-
Click OK to
return to the Computed Stack Column dialog box.
Notice that the Type Wizard has transferred the A250 to
the Type box. If you know the WebFOCUS abbreviation for your data
type, you can type it directly here. You will also notice, as you
continue to work in a project, that WebFOCUS Maintain saves the
data types you have applied and lists them.
-
Click OK to
return to the Stack Editor.
-
Click OK to
confirm your new stack and close the Stack Editor.
x
Procedure: How to Execute Report Output Into a Stack
-
Create
a new function in Start named ShowAllFans.
-
Double-click ShowAllFans to
open it in the Procedure Editor.
-
Type
the following text between Case ShowAllFans and EndCase:
EXEC fanrpt INTO HTMLSTACK;
Executing
the ShowAllFans function runs the report and returns the results
to HtmlStack.
-
Close
the Procedure Editor.
x
Procedure: How to Display Report Output in an HTML Object
-
Create
a new form to show the report output.
-
Name
the form Show_Fans_Form.
-
Give
the form the title Show All Fans.
-
Give
it the Spiralbg background image.
-
Place
the image Showall.gif at the top of the form.
-
Put a
Back button on the form that closes the form.
-
Add an
HTML Object to your form. In the Control palette, select the HTML
Object control,
and draw a box on your form.
-
Double-click
it to open the HTML Content Source dialog box.
The HTML Content Source dialog box enables you to specify
HTML code that determines what the HTML Object displays. You could
enter it directly here, but you want to use the report output from
fanrpt.
-
Change
Insert HTML content from As entered here to From
a variable.
-
Expand
HtmlStack.
-
Select HTML.
-
Click OK to
close the HTML Content Source dialog box.
-
Change
the Overflow property for the HTML Object to 2 - Scroll.
-
Close
Show_Fans_Form.
-
In the
Project Explorer, right-click Welcome_Form, and in the shortcut menu,
click Edit event handlers to open the Event
Handler editor.
-
In the
list of controls, select WelcomeMenu.
-
In the
list of events, select ClickShowAllFans.
-
Drag
ShowAllFans from the Project Explorer into the Event Handler editor.
-
Drag
Show_Fans_Form from the Project Explorer into the Event Handler editor
and select Show a Form from the pop-up menu.
(Be sure to select Show_Fans_Form and not ShowFan.)
-
Close
the Event Handler editor.
-
Deploy
and run your application.
x
If you run your application, and enter and leave Show_Fans_Form
multiple times in one session, you will notice that Show_Fans_Form
displays multiple copies of the report.
Each time you enter Show_Fans_Form, WebFOCUS Maintain re-executes
the report and places it in HtmlStack.HTML. This is Maintain language
shorthand for the HTML column of the stack HtmlStack. However, since
you did not clear the contents of HtmlStack.HTML before re-executing
the report, the new report results get appended to whatever is already in
the stack. You must clear HtmlStack before executing the report.
x
Procedure: How to Clear HtmlStack
-
Open
Start in the Procedure Editor.
-
Find
Case ShowAllFans.
-
Before
the line that executes the report (Exec fanrpt INTO HTMLSTACK;),
enter the following code:
Stack clear HtmlStack ;
You
can either type this code or use the Language Wizard to enter it.
-
Close
Start, save your project, and deploy and run it.
-
Try entering
Show_Fans_Form more than once. The stack is clear.