Edit D:\app\Administrator\product\11.2.0\dbhome_1\apex\images\doc\tutorial\check_box.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- Run date = February 23, 2005 16:58:37 --> <meta name="Generator" content=" Oracle DARB XHTML converter - Version 4.1.3 Build 116" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title> How to Work with Check Boxes</title> <link rel="stylesheet" type="text/css" href="blafdoc.css" title="default" /> <link rel="stylesheet" type="text/css" href="darbbook.css" title="default" /> <link rel="prev" href="frm_layout.htm" title="Previous" /> <link rel="next" href="web_serv.htm" title="Next" /> <link rel="up" href="toc.htm" title="Up" /> <link rel="contents" href="toc.htm" title="Contents" /> <link rel="copyright" href="./support/html/cpyr.htm" title="Copyright" /> <link rel="index" href="index.htm" title="Index" /> </head> <body> <div class="header"> <a id="top" name="top"></a> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="left" valign="top"> <b>Oracle® HTML DB Guide to Building Applications </b> <br /> <b>Release 2.0 </b> </td> <td valign="bottom" align="right"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225"> <tr><td> </td> <td align="center" valign="top"><a href="toc.htm"><img src="./support/gifs/toc.gif" alt="Go To Table Of Contents" border="0" /><br /><span class="icon">Contents</span></a></td> </table> </td> </tr> </table> <hr /> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100"> <tr> <td align="center"> <a href="frm_layout.htm"> <img src="./support/gifs/leftnav.gif" alt="Previous" border="0" /><br /><span class="icon">Previous</span></a> </td> <td align="center"> <a href="web_serv.htm"> <img src="./support/gifs/rightnav.gif" alt="Next" border="0" /><br /><span class="icon">Next</span></a> </td> <td> </td> </tr> </table> </div><!-- class="header" --> <div class="IND"> <!-- End Header --><a id="CHDDFBFH" name="CHDDFBFH"></a><a id="sthref102" name="sthref102"></a> <h1><a name="HTMAD005"></a>How to Work with Check Boxes</h1> <p>In Oracle HTML DB, you can create check boxes as form elements, or you can create check boxes in reports. Check boxes on a form work similarly to lists of values. When you define an item to be a check box, you need to provide the check box values in the List of Values section of the Item Attributes page. You define check boxes on a report using the supplied function <code>HTMLDB_ITEM.CHECKBOX</code>. </p> <p>This tutorial illustrates the different ways you can create check boxes within the demonstration application, <span class="italic">Sample Application</span> and explains how to reference and process the values of checked boxes. </p> <p class="subhead2">Topics:</p> <ul> <li type="disc"> <p><a href="#BCEJDIEG">Accessing Sample Application</a> </p> </li> <li type="disc"> <p><a href="#CHDFBGGD">Creating a Single Value Check Box on a Form</a> </p> </li> <li type="disc"> <p><a href="#CHDBGDJH">Creating Multi Value Check Box to Filter Content</a> </p> </li> <li type="disc"> <p><a href="#CHDHFACG">Adding Check Boxes to Each Row in the Report</a> </p> </li> </ul><a id="BCEJDIEG" name="BCEJDIEG"></a> <div class="sect1"> <!-- infolevel=all infotype=General --><a id="sthref103" name="sthref103"></a> <h2>Accessing Sample Application </h2> <p>To access Sample Application: </p> <ol type="1" start="1"> <li> <p>Log in to Oracle HTML DB. </p> </li> <li> <p>From the Workspace Administration list, select <span class="bold">Review Demonstration Applications</span>. </p> </li> <li> <p>Locate Sample Application and check the Status column: </p> <ol type="a"> <li> <p>If the Status column displays <span class="bold">Installed</span>, click <span class="bold">Run</span> in the Action column. </p> </li> <li> <p>If the Status column displays <span class="bold">Not Installed</span>, select <span class="bold">Install</span> in the Action column. When the Application Builder home page appears, click the <span class="bold">Run</span> icon. </p> </li> </ol> </li> <li> <p>When prompted, enter the appropriate username and password and click <span class="bold">Login</span> </p> <ul> <li type="disc"> <p>For User Name, enter either <code>demo</code> or <code>admin</code>. </p> </li> <li type="disc"> <p>For Password, enter the name of the current workspace using all lowercase letters. </p> </li> </ul> </li> <li> <p>Navigate to the product information page by clicking the <span class="bold">Products</span> tab. </p> </li> <li> <p>Click the <span class="bold">Edit</span> icon to the left of a product. </p> <p>As shown in <a href="#BCEIHIAH">Figure 5-1</a>, note that Product Available is a radio group. In this exercise that follows you will change this item to a check box. </p> <div class="figure"> <a id="BCEIHIAH" name="BCEIHIAH"></a><a id="sthref104" name="sthref104"></a> <p class="titleinfigure">Figure 5-1 Products Available Radio Group</p> <img src="./img/chk_radio.gif" alt="Description of chk_radio.gif follows" title="Description of chk_radio.gif follows"/> <br /><a id="sthref105" name="sthref105" href="./img_text/chk_radio.htm">Description of the illustration chk_radio.gif</a> <br /><br /> </div><!-- class="figure" --> </li> </ol> </div><!-- class="sect1" --> <a id="CHDFBGGD" name="CHDFBGGD"></a> <div class="sect1"> <!-- infolevel=all infotype=General --><a id="sthref106" name="sthref106"></a> <h2>Creating a Single Value Check Box on a Form </h2> <p>In this exercise you change the Product Available radio group to a check box and then change the position of the label. </p> <p class="subhead2">Topics:</p> <ul> <li type="disc"> <p><a href="#CHDHJJFH">Change Product Available Radio Group to a Check Box</a> </p> </li> <li type="disc"> <p><a href="#CHDCEBFF">Alter the Check Box Position</a> </p> </li> <li type="disc"> <p><a href="#CHDFEJHB">Change Default Check Box Behavior</a> </p> </li> </ul><a id="CHDHJJFH" name="CHDHJJFH"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref107" name="sthref107"></a> <h3>Change Product Available Radio Group to a Check Box </h3> <p>To change the Product Available radio group to a check box: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 6. Select <span class="bold">Edit Page 6</span> from the Developer Toolbar. </p> </li> <li> <p>Under Items, select <span class="bold">P6_PRODUCT_AVAIL</span>. </p> </li> <li> <p>From Display As, select <span class="bold">Checkbox</span>. </p> </li> <li> <p>Scroll down to List of Values. </p> </li> <li> <p>Under List of Values: </p> <ol type="a"> <li> <p>From Named LOV, select <span class="bold">Select Named LOV</span>. </p> </li> <li> <p>In List of values definition, enter: </p> <pre xml:space="preserve" class="oac_no_warn">STATIC:;Y </pre> </li> </ol> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> <p>The Page Definition appears. </p> </li> <li> <p>Run the page by clicking the <span class="bold">Run Page</span> icon. </p> </li> </ol> <p>As shown in <a href="#CHDBFIBH">Figure 5-2</a>, note that the Product Available item now displays as a check box. </p> <div class="figure"> <a id="CHDBFIBH" name="CHDBFIBH"></a><a id="sthref108" name="sthref108"></a> <p class="titleinfigure">Figure 5-2 Product Available Item as a Check Box</p> <img src="./img/chk_check1.gif" alt="Description of chk_check1.gif follows" title="Description of chk_check1.gif follows"/> <br /><a id="sthref109" name="sthref109" href="./img_text/chk_check1.htm">Description of the illustration chk_check1.gif</a> <br /><br /> </div><!-- class="figure" --> </div><!-- class="sect2" --> <a id="CHDCEBFF" name="CHDCEBFF"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref110" name="sthref110"></a> <h3>Alter the Check Box Position </h3> <p>Next, you move the check box label to the right side of the check box. </p> <p>To change the position of the check box label: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 6. Select <span class="bold">Edit Page 6</span> from the Developer Toolbar. </p> </li> <li> <p>Under Items, select <span class="bold">P6_PRODUCT_AVAIL</span>. </p> </li> <li> <p>For Label, delete the text <code>Product Available</code>. </p> </li> <li> <p>Under List of Values, change the List of values definition to: </p> <pre xml:space="preserve" class="oac_no_warn">STATIC:Product Available;Y </pre> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> <li> <p>Run the page by clicking the <span class="bold">Run Page</span> icon. </p> </li> </ol> <p>As shown in <a href="#CHDDCAGH">Figure 5-3</a>, note that the label Product Available now displays to the right of the check box. </p> <div class="figure"> <a id="CHDDCAGH" name="CHDDCAGH"></a><a id="sthref111" name="sthref111"></a> <p class="titleinfigure">Figure 5-3 Product Available Label Moved to the Right</p> <img src="./img/chk_check2.gif" alt="Description of chk_check2.gif follows" title="Description of chk_check2.gif follows"/> <br /><a id="sthref112" name="sthref112" href="./img_text/chk_check2.htm">Description of the illustration chk_check2.gif</a> <br /><br /> </div><!-- class="figure" --> <p>Removing the label and adding the display value to the LOV causes the HTML DB engine to render the check box first and then the display value, Product Available. </p> </div><!-- class="sect2" --> <a id="CHDFEJHB" name="CHDFEJHB"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref113" name="sthref113"></a> <h3>Change Default Check Box Behavior </h3> <p>In certain circumstances, you may want a check box to be enabled by default. You can accomplish this by setting the default value attribute of the check box item. One disadvantage of this approach is that you need to perform some extra steps to disable it. Because of the way you defined the Product Available check box, it is virtually impossible to disable it. </p> <p>Consider the following example: </p> <ol type="1" start="1"> <li> <p>Navigate to the Home page by selecting the <span class="bold">Home</span> tab. </p> </li> <li> <p>From the Tasks list, select <span class="bold">Add a New Product</span>. </p> </li> <li> <p>On the Add/Modify Product page: </p> <ol type="a"> <li> <p>Fill in the required fields (fields marked with an asterisk). </p> </li> <li> <p>Disable the <span class="bold">Product Available</span> check box. </p> </li> <li> <p>Click <span class="bold">Create</span>. </p> </li> </ol> </li> <li> <p>Disable the Product Available check box again and click <span class="bold">Apply Changes</span>. </p> <p>The Product Page appears. </p> </li> <li> <p>Select the <span class="bold">Edit</span> icon for product you just added. </p> <p>Notice that the Product Available check box is enabled even though you disabled it twice when you added the product. This behavior results from the fact: </p> <ul> <li type="disc"> <p>The Product Available check box has a default value of <code>Y</code>. </p> </li> <li type="disc"> <p>When Product Available is <code>NULL</code>, it defaults to the default value <code>Y</code> which enables the check box. </p> </li> </ul> </li> </ol> <div class="sect3"> <!-- infolevel=all infotype=General --><a id="sthref114" name="sthref114"></a> <h4>Add a Computation </h4> <p>You can alter this behavior by adding a computation that remembers the state of the check box. </p> <p>To add a computation that tracks the state of the check box: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 6. Select <span class="bold">Edit Page 6</span> from the Developer Toolbar. </p> </li> <li> <p>Under Computations, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>For Location, select <span class="bold">Item on This Page</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>On Identify Item: </p> <ol type="a"> <li> <p>For Computer Item, select <span class="bold">P6_PRODUCT_AVAIL</span>. </p> </li> <li> <p>For Computation Point, select <span class="bold">After Submit</span>. </p> </li> <li> <p>For Computation Type, select <span class="bold">Static Assignment</span>. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>For Computation, enter the following and click <span class="bold">Next</span>. </p> <pre xml:space="preserve" class="oac_no_warn">N </pre> <div align="center"> <div class="inftblNote"> <br /><table class = "Note oac_no_warn" summary="This is a layout table to format a note" title="This is a layout table to format a note" dir="ltr" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0"> <tbody> <tr> <td align="left"> <p class="notep1">Note:</p>A static assignment of an item needs to be something other than <code>Y</code> or <code>NULL</code>. </td> </tr> </tbody> </table><br /> </div><!-- class="inftblNote --> </div> <p>Next, create a condition that controls when the computation executes. </p> </li> <li> <p>On Identify Condition: </p> <ol type="a"> <li> <p>For Condition Type, select <span class="bold">Value of Item in Expression 1 is NULL</span>. </p> </li> <li> <p>In Expression 1, enter: </p> <pre xml:space="preserve" class="oac_no_warn">P6_PRODUCT_AVAIL </pre> <p>Because of these settings, this computation will only execute when the value of the check box item, P6_PRODUCT_AVAIL is <code>NULL</code>. </p> </li> </ol> </li> <li> <p>Click <span class="bold">Create</span>. </p> </li> </ol> <p>Add another product as you did in the previous procedure. Notice that this time the Product Available check box is not automatically selected. </p> </div><!-- class="sect3" --> </div><!-- class="sect2" --> </div><!-- class="sect1" --> <a id="CHDBGDJH" name="CHDBGDJH"></a> <div class="sect1"> <!-- infolevel=all infotype=General --><a id="sthref115" name="sthref115"></a> <h2>Creating Multi Value Check Box to Filter Content </h2> <p>In the next exercise, you create a multiple check boxes on the Product page. This check box will enable users to filter the report by selecting a category. </p> <p class="subhead2">Topics:</p> <ul> <li type="disc"> <p><a href="#CHDEGBAF">Create a Multi Value Check Box</a> </p> </li> <li type="disc"> <p><a href="#CHDHHBBI">Alter Check Box Display Values</a> </p> </li> <li type="disc"> <p><a href="#CHDCHCFG">Change Where the Check Boxes Display</a> </p> </li> <li type="disc"> <p><a href="#CHDBDIDC">Create a Go Button to Submit the Page</a> </p> </li> <li type="disc"> <p><a href="#CHDHEIEE">Adjust Default Check Box Behavior</a> </p> </li> </ul><a id="CHDEGBAF" name="CHDEGBAF"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref116" name="sthref116"></a> <h3>Create a Multi Value Check Box </h3> <p>To create muli value check box: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Items, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>For Choose Item Type, select <span class="bold">Check Box</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>On Identify Item Name and Display Position: </p> <ol type="a"> <li> <p>For Item Name, enter <code>P3_SHOW</code>. </p> </li> <li> <p>For Region, select <span class="bold">Products 1.10</span>. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>On Identify List of Values: </p> <ol type="a"> <li> <p>For Display Null Option, select <span class="bold">No</span>. </p> </li> <li> <p>In List of Values Query, enter: </p> <pre xml:space="preserve" class="oac_no_warn">SELECT distinct category a, category b FROM demo_product_info ORDER BY 1 </pre> <p>Note that to create a multi value check box, the List of Values query needs to return more than one row. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>On Identify Item Attributes: </p> <ol type="a"> <li> <p>For Label, remove the default text by clicking <span class="bold">Clear</span>. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>On Identify Item Attributes: </p> <ol type="a"> <li> <p>For Item Source, select <span class="bold">Static Assignment</span>. </p> </li> <li> <p>For Item Source Value, enter: </p> <pre xml:space="preserve" class="oac_no_warn">Audio:Computer:Phones:Video </pre> <p>When a multi value check box is submitted, the value of the item is a colon delimited string of values. Using this string as the source will ensure all boxes are checked when HTML DB engine renders the page. </p> </li> <li> <p>Click <span class="bold">Create Item</span>. </p> </li> </ol> </li> </ol> </div><!-- class="sect2" --> <a id="CHDHHBBI" name="CHDHHBBI"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref117" name="sthref117"></a> <h3>Alter Check Box Display Values </h3> <p>To edit check box display values (or labels) to appear in bold: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Items, select <span class="bold">P3_SHOW</span>. </p> </li> <li> <p>Scroll down to Element. </p> </li> <li> <p>In Form Element Option Attributes, enter: </p> <pre xml:space="preserve" class="oac_no_warn">class="fielddatabold" </pre> <p>Form Element Option Attributes are used exclusively for check boxes and radio buttons and control the way the HTML DB engine renders individual options. </p> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> </ol> </div><!-- class="sect2" --> <a id="CHDCHCFG" name="CHDCHCFG"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref118" name="sthref118"></a> <h3>Change Where the Check Boxes Display </h3> <p>Next, you edit attributes so that the category check boxes display above the report. To accomplish this, you need to change the Display Point attribute of the region associated with P3_SHOW. </p> <p>To change the display point of the Products region: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Region, select <span class="bold">Products</span>. </p> </li> <li> <p>From Display Point, select <span class="bold">Page Template Body (3. items above region content)</span>. </p> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> </ol> <p>If you ran page 3 now, you would notice the category check boxes display vertically. Next, you will change the display so the category check boxes display horizontally. </p> <p>To alter where the category check boxes display: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Items, select <span class="bold">P3_SHOW</span>. </p> </li> <li> <p>Scroll down to List of Values. </p> </li> <li> <p>In Columns, enter <code>4</code>. </p> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> </ol> </div><!-- class="sect2" --> <a id="CHDBDIDC" name="CHDBDIDC"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref119" name="sthref119"></a> <h3>Create a Go Button to Submit the Page </h3> <p>In order for the report to be driven by the product category check boxes, you need to submit the page. </p> <p>To create a button to submit the page: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Buttons, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>For Select a region for the button, select <span class="bold">Products 1.10</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>For Task, select <span class="bold">Create a button displayed among this region's items</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>On Identify Button within Items Attributes: </p> <ol type="a"> <li> <p>For Button Name, enter <code>P3_GO</code>. </p> </li> <li> <p>In Sequence, enter 40. </p> </li> <li> <p>Click <span class="bold">Create Button</span>. </p> </li> </ol> </li> </ol> <p>Next, you need to create a branch to tell the HTML DB engine where to go after the user clicks the Go button. </p> <p>To create a branch to page 3: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Branches, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>On Identify Branch Point and Type, accept the defaults and click <span class="bold">Next</span>. </p> </li> <li> <p>For Page, select <span class="bold">3</span><span class="bold"></span> and click <span class="bold">Next</span>. </p> </li> <li> <p>Click <span class="bold">Create Branch</span>. </p> </li> </ol> <p>In order to generate a report based on the category check box values, you need to change the report query. </p> <p>To edit the report query: </p> <ol type="1" start="1"> <li> <p>Under Region, select <span class="bold">Products</span>. </p> </li> <li> <p>Scroll down to Region Source. </p> </li> <li> <p>In Region Source, change the <code>WHERE</code> clause to read: </p> <pre xml:space="preserve" class="oac_no_warn">WHERE p.image_id = i.image_id (+)AND instr(':'||:P3_SHOW||':',category) > 0 </pre> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> <li> <p>Run the page by clicking the <span class="bold">Run Page</span> icon. </p> </li> </ol> <p>As shown in <a href="#BCEJDIJF">Figure 5-4</a>, notice you can filter the report by selecting a category check box at the top of the page. </p> <div class="figure"> <a id="BCEJDIJF" name="BCEJDIJF"></a><a id="sthref120" name="sthref120"></a> <p class="titleinfigure">Figure 5-4 Product Page with Category Check Boxes and Go Button</p> <img src="./img/chk_chkboxs.gif" alt="Description of chk_chkboxs.gif follows" title="Description of chk_chkboxs.gif follows"/> <br /><a id="sthref121" name="sthref121" href="./img_text/chk_chkboxs.htm">Description of the illustration chk_chkboxs.gif</a> <br /><br /> </div><!-- class="figure" --> </div><!-- class="sect2" --> <a id="CHDHEIEE" name="CHDHEIEE"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref122" name="sthref122"></a> <h3>Adjust Default Check Box Behavior </h3> <p>Although the category check boxes correctly filters the content on page 3, if you deselect all the check boxes, notice the report returns all products. This behavior results from the fact that if a check box has a NULL value (that is, it is deselected), it defaults to the default value Y. The default value of Y in turn enables the check box. </p> <p>You can alter this behavior by adding a computation that remembers the state of the check box. </p> <p>To add a computation that tracks the state of the check box: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Computations, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>For Location, select <span class="bold">Item on This Page</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>On Identify Item: </p> <ol type="a"> <li> <p>For Computer Item, select <span class="bold">P3_SHOW</span> </p> </li> <li> <p>For Computation Point, select <span class="bold">After Submit</span>. </p> </li> <li> <p>For Computation Type, select <span class="bold">Static Assignment</span>. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>On Identify Computation: </p> <ol type="a"> <li> <p>For Computation: </p> <pre xml:space="preserve" class="oac_no_warn">none(bogus_value) </pre> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> <div align="center"> <div class="inftblNote"> <br /><table class = "Note oac_no_warn" summary="This is a layout table to format a note" title="This is a layout table to format a note" dir="ltr" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0"> <tbody> <tr> <td align="left"> <p class="notep1">Note:</p>A static assignment of an item needs to be something other than <code>Y</code> or <code>NULL</code>. </td> </tr> </tbody> </table><br /> </div><!-- class="inftblNote --> </div> <p>Next, create a condition that controls when the computation executes. </p> </li> <li> <p>On Identify Condition: </p> <ol type="a"> <li> <p>For Condition Type, select <span class="bold">Value of Item in Expression 1 is NULL</span>. </p> </li> <li> <p>In Expression 1, enter: </p> <pre xml:space="preserve" class="oac_no_warn">P3_SHOW </pre> <p>As a result of these settings, this computation will only execute when the value of the check box item, <code>P3_SHOW</code> is <code>NULL</code>. </p> </li> </ol> </li> <li> <p>Click <span class="bold">Create</span>. </p> </li> </ol> <p>Run the page again and deselect all the category check boxes. Notice that this time the report contains the expected result (no returned records). </p> </div><!-- class="sect2" --> </div><!-- class="sect1" --> <a id="CHDHFACG" name="CHDHFACG"></a> <div class="sect1"> <!-- infolevel=all infotype=General --><a id="sthref123" name="sthref123"></a> <h2>Adding Check Boxes to Each Row in the Report </h2> <p>In the next exercise you add a delete check box to each row in the Products report. To accomplish this you will edit the report query and make a call to <code>HTMLDB_ITEM</code> package. </p> <p><code>HTMLDB_ITEM</code> is a supplied package for generating certain form elements dynamically. In this instance, you will use <code>HTMLDB_ITEM.CHECKBOX</code> to generate check boxes in the Products report. When the page is submitted, the values of the check boxes are stored in global package arrays. You can reference these values using the PL/SQL variables <code>HTMLDB_APPLICATION.G_F01</code> to <code>HTMLDB_APPLICATION.G_F50</code> based on the <code>p_idx</code> parameter value that was passed in. </p> <p class="subhead2">Topics:</p> <ul> <li type="disc"> <p><a href="#CHDCGIFA">Call HTMLDB_ITEM.CHECKBOX</a> </p> </li> <li type="disc"> <p><a href="#CHDCHGDD">Add a Button to Submit Check Box Array Values</a> </p> </li> <li type="disc"> <p><a href="#CHDHFGEJ">Add a Process</a> </p> </li> </ul><a id="CHDCGIFA" name="CHDCGIFA"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref124" name="sthref124"></a> <h3>Call HTMLDB_ITEM.CHECKBOX </h3> <p>To edit the query to call <code>HTMLDB_ITEM.CHECKBOX</code>: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Regions, click <span class="bold">Products</span>. </p> </li> <li> <p>In Region Source, add the new line appearing in bold face to the query. </p> <pre xml:space="preserve" class="oac_no_warn">SELECT p.product_id edit_product, p.product_id view_product_id, <span class="bold">htmldb_item.checkbox(1,p.product_id) del, </span> p.product_name, p.product_description, p.category, p.product_avail, p.list_price, '<img src="#OWNER#.custom_image_display?p_image_id=' || nvl(i.image_id,0) || '" height="50" width="50" />' img FROM demo_product_info p, demo_images i WHERE p.image_id = i.image_id (+) AND instr(':'||:P3_SHOW||':',category) > 0 </pre> <p>HTMLDB_ITEM is an Oracle HTML DB supplied package you can use to generate certain form elements dynamically. Note the value passed in for <code>p_idx</code> in the above example is 1. You will reference the check box values using the global variable <code>HTMLDB_APPLICATION.G_F01</code> later on. </p> </li> <li> <p>Select the <span class="bold">Report Attributes</span> tab. </p> </li> <li> <p>Under Report Column Attributes, locate the <code>Del</code> column. </p> </li> <li> <p>Click the Up arrow until the <code>DEL</code> column is directly beneath <code>VIEW_PRODUCT_ID</code>. (See <a href="#BCEGFBCF">Figure 5-5</a>). </p> <div class="figure"> <a id="BCEGFBCF" name="BCEGFBCF"></a><a id="sthref125" name="sthref125"></a> <p class="titleinfigure">Figure 5-5 Report Column Attributes Page</p> <img src="./img/chk_rpt_attr.gif" alt="Description of chk_rpt_attr.gif follows" title="Description of chk_rpt_attr.gif follows"/> <br /><a id="sthref126" name="sthref126" href="./img_text/chk_rpt_attr.htm">Description of the illustration chk_rpt_attr.gif</a> <br /><br /> </div><!-- class="figure" --> </li> <li> <p>Click <span class="bold">Apply Changes</span>. </p> </li> </ol> </div><!-- class="sect2" --> <a id="CHDCHGDD" name="CHDCHGDD"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref127" name="sthref127"></a> <h3>Add a Button to Submit Check Box Array Values </h3> <p>To add a button to submit the check box array values: </p> <ol type="1" start="1"> <li> <p>Navigate to the Page Definition for page 3. </p> </li> <li> <p>Under Buttons, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>For Select a region for the button, select <span class="bold">Products 1.10</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>For Task, select, select <span class="bold">Create a button in a region position</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>On Identify Button within Items Attributes: </p> <ol type="a"> <li> <p>For Button Name, enter <code>DELETE_PRODUCTS</code>. </p> </li> <li> <p>For Label, enter <code>Delete Products</code>. </p> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>For Button Template, accept the default selection and click <span class="bold">Next</span>. </p> </li> <li> <p>For Position, select <span class="bold">Top of Region</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>For Branch to Page, select <span class="bold">3</span> and click <span class="bold">Create Button</span>. </p> </li> </ol> </div><!-- class="sect2" --> <a id="CHDHFGEJ" name="CHDHFGEJ"></a> <div class="sect2"> <!-- infolevel=all infotype=General --><a id="sthref128" name="sthref128"></a> <h3>Add a Process </h3> <p>To add process that executes when the user clicks the Delete Products button: </p> <ol type="1" start="1"> <li> <p>Under Processes, click the <span class="bold">Create</span> icon. </p> </li> <li> <p>On Select Process Type, select <span class="bold">PL/SQL</span> and click <span class="bold">Next</span>. </p> </li> <li> <p>For Name, enter <span class="bold">Delete Products</span>. </p> </li> <li> <p>Enter following PL/SQL process and click <span class="bold">Next</span>: </p> <pre xml:space="preserve" class="oac_no_warn">FOR i in 1..HTMLDB_APPLICATION.G_F01.count LOOP DELETE FROM demo_product_info WHERE product_id = HTMLDB_APPLICATION.G_F01(i); END LOOP; </pre> <p><code>HTMLDB_ITEM</code> is an Oracle HTML DB supplied package you can use to generate certain form elements dynamically. When a page is submitted, the values of each column are stored in global package arrays, which you can reference using the PL/SQL variable <code>HTMLDB_APPLICATION.G_F01</code> to <code>HTMLDB_APPLICATION.G_F50</code>. In this exercise, the value passed in for <code>p_idx</code> in <code>EMPNO</code> column is 1, so you reference the <code>EMPNO</code> column values using the global variable <code>HTMLDB_APPLICATION.G_F01</code>. </p> </li> <li> <p>On Identify Messages: </p> <ol type="a"> <li> <p>In Success Message, enter: </p> <pre xml:space="preserve" class="oac_no_warn">Product(s) deleted. </pre> </li> <li> <p>In Failure Message, enter: </p> <pre xml:space="preserve" class="oac_no_warn">Unable to delete product(s). </pre> </li> <li> <p>Click <span class="bold">Next</span>. </p> </li> </ol> </li> <li> <p>Click <span class="bold">Create Process</span>. </p> </li> </ol> <p>If you run the page, the Delete Products button appears above the report. (See <a href="#CHDFCGAE">Figure 5-6</a>). To remove a product from the report, select the <span class="bold">Del</span> check box and click <span class="bold">Delete Products</span>. </p> <div class="figure"> <a id="CHDFCGAE" name="CHDFCGAE"></a><a id="sthref129" name="sthref129"></a> <p class="titleinfigure">Figure 5-6 Products Report with Delete Products Check Box</p> <img src="./img/chk_del_prod.gif" alt="Description of chk_del_prod.gif follows" title="Description of chk_del_prod.gif follows"/> <br /><a id="sthref130" name="sthref130" href="./img_text/chk_del_prod.htm">Description of the illustration chk_del_prod.gif</a> <br /><br /> </div><!-- class="figure" --> </div><!-- class="sect2" --> </div><!-- class="sect1" --> </div> <!-- Start Footer --> <div class="footer"> <hr /> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <tr> <td valign="bottom" width="33%"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100"> <tr><td> </td> <td align="center"> <a href="frm_layout.htm"> <img src="./support/gifs/leftnav.gif" alt="Previous" border="0" /><br /><span class="icon">Previous</span></a> </td> <td align="center"> <a href="web_serv.htm"> <img src="./support/gifs/rightnav.gif" alt="Next" border="0" /><br /><span class="icon">Next</span></a> </td> </tr> </table> </td> <td class="copyrightlogo"> <a href="./support/html/cpyr.htm"> <span class="copyrightlogo"> Copyright © 2005, Oracle. All rights reserved. </span> </a> </td> <td valign="bottom" align="right" width="33%"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225"> <tr><td> </td> <td align="center" valign="top"><a href="toc.htm"><img src="./support/gifs/toc.gif" alt="Go To Table Of Contents" border="0" /><br /><span class="icon">Contents</span></a></td> </table> </td> </tr> </table> </div><!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de