In this section: |
You can add fans to the WebFOCUS FanClub application, but what happens when you want to update or remove fans? You need to create a form where you can change information about a fan or remove a fan from the data source.
This section is divided into the following:
How to: |
The end user will open the Update/Delete form by selecting a fan from the list of fans in the ShowFan form. As you will recall from the Basic Tutorial, ShowFan uses an HTML Table to display the contents of the data source stack GetFanStack, which contains all of the fans in the fannames data source. The following image illustrates the front end of the ShowFan and Update/Delete forms.
The application will determine which row the end user selected using the ClickRow syntax:
formname.tablename.ClickRow
The header row returns 0, and the first data row returns 1.
In order to take advantage of this feature, you need to enable links for the HTML Table, which you do by opening the HTML Table Control Columns dialog box, and then opening the Table Column dialog box for the Last column.
You also need to use the special ClickLink event instead of the Click event. ClickLink is unique to HTML Tables.
The row that the end user clicks in the HTML Table corresponds to the row in GetFanStack that you want to display in the Update/Delete form. Each data source stack has an associated variable called FocIndex, which determines what the current row is. When the end user clicks a row in the HTML Table on ShowFan, the FanClub application needs to set FocIndex to whatever the value of the row is. It does this using the COMPUTE command. It then opens the Update/Delete form.
The syntax of the COMPUTE command is
COMPUTE variable = expression;
where:
Is the FocIndex of GetFanStack (written GetFanStack.FocIndex).
Is ShowFan.HTMLTable1.ClickRow.
For the complete syntax of COMPUTE, see Command Reference in the Maintain Language Reference manual.
COMPUTE GetFanStack.FocIndex = ShowFan.HTMLTable1.ClickRow; Winform Show Update_Form;
Tip: You can drag GetFanStack.FocIndex and Update_Form from the Project Explorer to the Event Handler editor to generate this syntax. You will have to expand GetFanStack in the Project Explorer to see FocIndex. You will have to type the rest of the syntax.
How to: |
Your next step is to place controls on Update_Form. This form should look almost exactly like Form1. Making your forms look similar this way makes it easier for end users to learn your application, because forms that perform similar tasks work the same way. In fact, before you start developing your own applications, developing a template for the application is recommended.
For more tips on developing forms, see Developing and Using Forms in the Developing WebFOCUS Maintain Applications manual.
WebFOCUS Maintain opens the Select Stack Columns dialog box, as shown in the following image.
WebFOCUS places prompted edit fields for all of these columns on Update_Form.
Then click the Center vertically button .
(This command does not actually center the controls. Instead it aligns the prompted edit boxes by the left sides of the edit boxes.)
Note: You cannot name the Update button "Update" because Update is a reserved word. Reserved words are command names, built-in function names, keywords, and other WebFOCUS terms that could cause unpredictable behavior if you use them to name components of your application.
However, there is no reason the text on the button (what the end user sees) cannot say Update.
For a complete list of reserved words, see Language Rules Reference in the Maintain Language Reference manual.
How to: |
Update_Form now looks almost like Form1 except that it has a slightly different purpose. However, Form1 has a group of radio buttons that enables the end user to supply the title of a fan (Mr., Mrs., or Ms.), and Update_Form needs this same set of radio buttons.
Rather than creating new radio buttons, you can copy them from Form1 and paste them into Update_Form.
WebFOCUS Maintain performs two types of copying; deep copy and shallow copy. When you perform a deep copy, WebFOCUS Maintain copies both the appearance of a control and any underlying data bindings, event handlers, and connections to resources. When you perform a shallow copy, WebFOCUS Maintain copies appearance only.
What happens if you perform a deep copy of the radio buttons from Form1 into Update_Form? You will see the three options (Mr., Mrs., and Ms.) and the tool tip text (Please select one) and the radio buttons will be bound to AddFanStack.TITLE (the TITLE column of AddFanStack). Since Update_Form uses GetFanStack, you need to change this binding to GetFanStack.TITLE. If you perform a shallow copy, you will see the three options and the tool tip text only. So, you do not save any time by using either a deep copy or a shallow copy.
You also need a Back button to close the form and return to the ShowFan form. The form ShowFan has a Back button, so you can copy it from here. If you perform a deep copy, you will get the button and the event handler self.WinClose (). If you perform a shallow copy, you will get the button only. You will have to reassign the event handler.
(If you wish, double-click the Back button to open the Event Handler editor to see that the self.WinClose (); syntax is still there.)
You can always perform a shallow copy, but sometimes you cannot perform a deep copy. For example, if you copied the radio buttons from Form1 and tried to do a deep copy into another form in another procedure, you would no longer see the data binding to AddFanStack.TITLE, because AddFanStack is only defined in the context of the Start procedure. The new procedure does not know what AddFanStack is, so it loses the binding.
WebFOCUS |