19 c custom form

Upload: bharti-goyal

Post on 03-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 19 c Custom Form

    1/8

    1

    Chapter 6: Creating Custom Forms

    Lesson C Slides

    Converting a Data Block to a Control Block

    Often, control blocks contain multiple text items from a single database table.

    Use Data Block and layout Wizards to create a data block form and a form layout andthen convert it into a control block and add command buttons and text items from othertables.

    To convert a data block to control block:1. Change the data blocks Database Data Block property value to No.2. Change the Required property value of the text item that represents the data block

    tables primary key to No.

    Inventory Data Block Property Palette INV_ID Property Palette

    Database Data Block NO

    Required NO

    2

    Inventory Items Frame Property Palette UPDATE buttons Property Palette

    WHEN-BUTTON-PRESSED trigger for UPDATE button

    Linking a Data Block to a Control Block

    The linked control/data blocks represent a master-detail relationship. The control block represents the master records and the data block represents the detail

    records.

    The Orders Control block has to be linked to Order Summary data block. The followingsteps are required:

    1. Create the control block2. Create the data block3. Specify the link between the control block and the data block4. Modify form triggers to refresh the data block when the underlying data values

    change

    Update Layout Manually

    Name UPDATE_BUTTON

    Label Update

    UPDATE inventorySET item_id = :inventory.item_id,

    color = :inventory.color,inv_size = :inventory.inv_size,inv_price = :inventory.inv_price,inv_qoh = :inventory.inv_qoh

    WHERE inv_id = :inventory.inv_id;COMMIT;MESSAGE(record successfully updated.);

    CLEAR_FORM;

  • 8/12/2019 19 c Custom Form

    2/8

    3

    Order Summary Data Block

    Each field name that might be duplicated in the data block must be given a uniquename

    Order Summary view:

    CREATE OR REPLACE VIEW order_summary ASSELECT o_id, inventory.inv_id, ol_quantity, item_desc, inv_size, color,

    inv_priceFROM order_line, item, inventoryWHERE order_line.inv_id = inventory.inv_idAND inventory.item_id = item.item_id;

    When you display a control block and a data block on the same canvas, you cannotdirectly create a master/detailrelationship between the data block and the control

    block.

    Select all fields from the view except O_ID as it is used for master/detail relationship

    4

    Data Block page(Layout Wizard)

    Displayed Items (in this order)

    INV_IDITEM_DESCCOLOR

    INV_SIZEOL_QUANTITYINV_PRICE

    Items page

    Name Prompt W H

    INV_D Inv. ID 35 14ITEM_DESC Description 80 14COLOR Color 75 14INV_SIZE Size 35 14OL_QUANTITY Quantity 25 14INV_PRICE Price 41 14

    Linking the Control Block and the Data Block

    Modify the data blocks WHERE property on its Property Palette so that the matchingkey field on the data block is equal to the value of the master key field on the control

    block.

    The general format of the WHERE property is as follows:

    WHERE data_block_fieldname = :control_block.control_block_fieldname

    ORDER_SUMAMRY Data Blocks Property Palette

    Refreshing the Data Block Values

    Savebutton trigger (Orders frame)

    WHERE O_ID = :ORDERS.O_ID

    GO_BLOCK(ORDER_SUMMARY);EXECUTE_QUERY;

  • 8/12/2019 19 c Custom Form

    3/8

    5

    1. Copy the same commands for the Save New Line, Update Order Lineand DeleteOrder Linebuttons triggers.

    Working with a Form with Multiple Canvasses

    At Clearwater Traders, new customer orders are entered using an on-screen form thatthe customer service representative completes when the customer calls the company.

    The first canvas displays customer information, and calls a second canvas that allowsthe customer service representative to enter order information.

    The application then switches to a third canvas that displays information about theindividual order items.

    Two approaches for creating applications with multiple screens:

    1. The single-formapproach involves creating one form with multiple canvases. This allows data to be easily shared among the different canvases of the same

    application at the same time, since the .fmb file can only be opened by oneprogrammer at a time.

    2. The multiple-formapproach involves creating multiple forms with a different .fmbfiles for each canvas in the application.

    This approach works well when multiple programmers are collaborating tocreate a complex application.

    It also enables a form to be used in many different applications, thus avoidingredundant programming efforts.

    Data sharing among forms is more difficult in the multiple-form approach thanin the single-form approach, and must be done using global variables, which

    are variables whose assigned values are visible to different forms.

    6

  • 8/12/2019 19 c Custom Form

    4/8

    7

    8

  • 8/12/2019 19 c Custom Form

    5/8

    9

    Working with Multiple Canvases and Data Blocks

    In a form that contains multiple canvases, create the individual canvases and thenspecify to display the specific block items on a specific canvas.

    For a new data block, select the canvas name on which the block items are to appearon the layout Wizard Canvas page.

    To specify which canvas an item appears on, select the target canvas name from theCanvasproperty list in the Property Palette of the item.Specifying the Block Navigation Order

    When a form contains multiple data blocks and multiple canvases, you must specifywhich canvas initially appears when the user runs the form.

    The canvas that appears first is the canvas whose block items appear first under theData Blocks node.

    Navigating among Different Form Blocks and Canvases

    To move to a different canvas within a form, use the GO_ITEM command to switchthe form focus to an item (such as a text item or button) on the new canvas.

    The canvas that contains the item that has the forms focus is then displayed. The CUSTOMER canvas initially appears when the user first runs the Sales form. To display the ORDERS canvas when the user clicks the Create New Order button,

    execute GO_ITEM built-in to move form focus to an item in ORDERS block.

    GO_ITEM(ORDERS.O_ID);

    10

    Referencing Block Items within Form Triggers

    WHEN_BUTTON-PRESSEDtrigger for Create New Order button onCUSTOMER_CANVAS

    Creating and Configuring Tab Canvases in Forms

    Tab canvases are multi-page canvases that allow users to move between multiple canvassurfaces by selecting tabs at the top of the canvas.

    Creating a Tab Canvas

    A tab page is an object representing a surface that displays form items, and has a tab labelidentifier at the top.

    To create a form that contains a tab canvas, create the form, and then create a newcontent canvas in the form.

    Then create a tab canvas on the content canvas and configure the tab pages.

    SELECT o_id_sequence.NEXTVALINTO :orders.o_idFROM dual;:orders.o_date := SYSDATE;

    GO_ITEM(ORDERS.O_ID);

  • 8/12/2019 19 c Custom Form

    6/8

    11

    To create a tab canvas, use the Tab Canvas tool on the Layout Editor tool palette todraw the tab canvas area on the content canvas.

    Creating and Configuring Tab Pages

    When you use the Tab Canvas tool to create a new tab canvas, Forms Builder creates anew tab canvas object in the Object Navigator.

    12

    CUSTOMER_PAGE Property Palette ORDER_PAGEProperty Palette

    ORDER_LINE_PAGE Property Palette

    Creating Form Items on a Tab Canvas

    Now you can use the tab pages just as any content canvas. You can create items on the tab pages using the data Block Wizard, or by creating a

    control block and drawing text items directly on the tab canvases.

    Creating and Configuring Stacked Canvases in Form

    A stacked canvas is a canvas that lies on top of a content canvas. You can use a stacked canvas to hide canvas objects and then make the objects appear

    as needed.

    You create a stacked canvas by painting it in the desired position on an existingcontent canvas.

    Then configure the stacked canvas properties, and create the form items that are toappear on the stacked canvas.

    Write form triggers that contain commands to display the stacked canvas when it i sneeded and to hide the stacked canvas when it is not needed.

    Label Select Customer

    Background Color light grey

    Label CreateOrder

    Background Color light grey

    Label Enter/Edit Items

    Background Color light grey

  • 8/12/2019 19 c Custom Form

    7/8

    13

    Creating the Stacked Canvas

    To create a stacked canvas, open the Layout Editor and display the content canvas onwhich the stacked canvas is to appear.

    Then select the Stacked Canvas tool on the layout Editor tool palette, and draw thestacked canvas on the content canvas.

    14

    Configuring the Stacked Canvas Properties

    The area that you draw on the content canvas is called the stacked canvas viewport. The viewport is the portion of the stacked canvas that is visible when the stacked

    canvas appears. You can specify the viewport Widthand Heightproperties in the Property Palette or

    by adjusting the size in the layout Editor.

    You can also adjust the viewport X- and Y- positions on the background of the stackedcanvas through the Property Palette or by moving the canvas in the Layout Editor.

    DETAIL_STACKED_CANVASProperty Palette

    Visible No

    Viewport Width 375

    Viewport Height 125

    Background Color white

  • 8/12/2019 19 c Custom Form

    8/8

    15

    To create the relationship between the control block and the data block:

    ORDER_SUMMARY Data Block Property Palette

    Displaying and Hiding a Stacked Canvas

    To display a stacked canvas, move the form focus to the data block whose items areassociated with the stacked canvas, and then execute the SHOW_VIEW built-in todisplay the stacked canvas.

    SHOW_VIEW(stacked_canvas_name);

    WHERE o_id = :orders.o_id

    16

    Show Summarybutton on ORDER_LINE_CANVAS, ORDER_LINEData Block

    WHEN_BUTTON-PRESSEDtrigger for Show Summarybutton

    Place the Hide button in the ORDER_SUMMARY block.

    The ORDER_SUMMARY block displays five records at a time. When you create a new item in a block that uses a tabular style layout and shows

    multiple records, every block item displays once for each record.

    To make the button appear only once, change the buttons Number of Items displayedproperty to 1.

    Group Property of HideButtons in ORDER_SUMMARY Block

    WHEN_BUTTON-PRESSEDtrigger for Hidebutton

    Name SHOW_SUMMARY_BUTTONLabel Show Summary

    GO_BLOCK(ORDER_SUMMARY);SHOW_VIEW(DETAIL_STACKED_CANVAS);EXECUTE_QUERY;

    Name HIDE_BUTTON

    Label Hide

    Number of Items Displayed 1

    GO_BLOCK(ORDER_LINE);HIDE_VIEW(DETAIL_STACKED_CANVAS);