Tuto WEBDEV 25
154 Part 4: Internet site with data Displaying data in the page The "Form" page must display the product that is selected in the Looper control. In the page code, we are going to type the code used to: • find the product to display. • display data in the page. ▶ To display data in the page: 1. Press F2. The code editor displays the different page WLanguage events. 2. In the "Global declarations" event, write the following code below the code previously written: HReadSeekFirst(Product,ProductID,gnProductID) IF HFound(Product) THEN FileToScreen() END 3. Let’s take a look at this WLanguage code: • HReadSeekFirst is used to find the first record in the Product data file for which the ProductID item is equal to the value of gnProductID, corresponding to the parameter passed to the page. • HFound is used to check whether a record was actually found. This function is mainly required for the multi-user sites. It is used to avoid errors caused by the deletions performed by the other users. • FileToScreen is used to display in the controls the data found in the data file, for the current record. In our case, the current record corresponds to the record found by HReadSeekFirst . 4. Close the code editor. Displaying the form from the list of products Now, let’s see how to display the form of the product selected in the list of products. The principle is straightforward: the user will select the product in the Looper control and he will display the details via a link. This link already exists in the Looper control. ▶ First, we will modify the "PAGE_List_of_new_products" page so that the Link control opens the product description window. 1. Position the cursor on the "List of products" page: click "PAGE_List_of_products" in the open documents bar. 2. Display the description window of Link control: double-click the control. 3. In the "General" tab of the description window, in "Link action": • Select "Display a site page". • Select the "PAGE_Product_details" page. • Click the "Parameters" button. We are now going to define the parameter that will be passed to the page in order to display the details of selected product. 4. In the window that appears, you will find the name of the parameter declared in the event "Global declarations" of the page (gnProductID). All you have to do is select the control containing the parameter value. In our case, the product identifier is found in the "ATT_ID" attribute.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==