Persistent and Non-Persistent Maintain Data Applications

In this section:

WebFOCUS App Studio Maintain Data applications can be persistent or non-persistent.

Overview of Persistent Maintain Applications

The benefits of a persistent application are the following:

The disadvantages of a persistent application are the following:

Overview of Non-Persistent Maintain Applications

How to:

The benefits of a non-persistent application are the following:

The disadvantages of a non-persistent application are the following:

Note: In a non-persistent application:

Procedure: How to Create the Application

  1. From the Environments Tree panel, right-click an application folder, point to New, and click HTML/Document, as shown in the following image. If needed, create the domain first.

    The HTML/Document Wizard opens.

  2. Click Next.

    The Templates, Settings, and Themes dialog box opens.

  3. Click Finish.

Procedure: How to Add the Maintain Data

  1. From the Requests & Data Sources panel, click the down arrow next to the New icon, select Embedded Request, and then select New Maintain data, as shown in the following image.
    By default, for an Embedded Request, Request1 is created.
  2. Right-click the Request1 parameter and select Use data sources, as shown in the following image.

  3. From the Data Sources in Procedure dialog box, select New.
  4. Browse to the location of your Maintain Data data sources and select the one to use, in this case, the movies file, as shown in the following image.
  5. Click OK.

Procedure: How to Create the Stack

In the .mnt tab, add a loaddata case in the Maintain Data code to load the stack, as shown in the following image.

Note: The Winform Show_and_exit Form1 command makes the application non-persistent.

Procedure: How to Create the Form

  1. Click the htmlpage1 tab.
  2. From the Requests & Data Sources panel, expand Request1 and the Forms folder.
  3. Drag Form1 onto the canvas, as shown in the following image.
  4. When prompted to create a multipage control, click No.

Procedure: How to Display the Stack

  1. From the Requests & Data Sources panel, expand the Stacks folder.
  2. Right-click allstk and drag it onto the form, as shown in the following image.
  3. Select Create controls.

    Note: If you accidentally left-click allstk and fields are created, click the undo icon, and make sure to right-click the stack before you drag it onto the form.

  4. On the Parameters dialog box, select the first four fields, as shown in the following image.
  5. Right-click the Edit box value in the Control Type column on row 1 and select Html Table.
  6. Click OK.
  7. Highlight the Allstk label, as shown in the following image, and delete the label.

Procedure: How to Add the Connect Task

  1. Open the Tasks & Animations panel.
  2. Add the load task.
  3. In the Requests/Actions section, click the arrow for Requests selections, select Run Request, then select Request1, and then select Request1.Connect, as shown in the following image.
  4. Run the application.

    The output is:

Procedure: How to Add a Hyperlink

  1. Click the HTML table and open the Settings panel.
  2. Select Moviecode and change the Body hyperlink property to True, as shown in the following image.

Procedure: How to Add the Variables

  1. From the Requests & Data Sources panel, expand the Variables folder.
  2. Drag selval and then action onto the form. By default, they are named edit1 and edit2.
  3. Rename edit1 and edit2 to selval and action, as shown in the following image.

    To do so:

    1. Open the Properties panel.
    2. Click selval and change the Unique Identifier from edit1 to selval.
    3. Click action and change the Unique Identifier from edit2 to action.

    These are used to store and pass back values to Maintain Data. You can make them not visible (visible No) later.

Procedure: How to Add the Event

When you click the link, you want to return to the Maintain Data code, retrieve the record, and display it.

  1. Click the HTML table and open the Properties panel.
  2. Click the lightning bolt and double-click Click link, as shown in the following image.
  3. Since there are no Maintain Data tasks in a non-persistent Maintain Data application, you need to use JavaScript.
    • Store the selected value in selval.
    • Set action to 'G', as shown in the following code, to branch in the Maintain Data code.
      selval.value=IbComposer_getClickedCellValue(ctrl);
      action.value= 'G';
    • Open the Tasks & Animations panel and drag the load task into the event, as shown in the following image.

    Note: This requires a reconnect to Maintain Data every time.

Procedure: How to Update the Code

  1. Click the .mnt tab to type more code.
  2. Add an IF statement for when action equals 'G' and a Getdata case, as shown in the following image.
  3. Save the code.

Procedure: How to Add Fields to the Form

  1. Display the HTML form.
  2. From the Request & Data Sources panel, expand the Stacks folder and drag recstk onto the form. Left-click and drag for default fields, as shown in the following image.
  3. Save the code and run the application.
  4. Select a row in the HTML table.

    The output is:

  5. Open the Maintain Data code and add an UpdateData case with a test for action equal to 'U', as shown in the following image. The edit boxes and stacks get sent back to the code.
  6. Save the code.
  7. Draw a button on the form and change the text to Update.
  8. Open the Properties panel.
  9. Click the lightning bolt and double-click the Click event, as shown in the following image.
  10. In the JavaScript, update the action field, as shown in the following image.
  11. Reconnect to the Maintain Data code.
  12. Save the code and run the application.

    Note: Add and Delete are handled the same way.

Procedure: How to Add Other Objects

You can use other objects to display and collect data.
  1. Add the loadratestk case to display all valid ratings.
  2. Perform the load from both loaddata and Getdata.
  3. Add code into Getdata to autoscroll to the selected value, as shown in the following image.
  4. From the Requests & Data Sources panel, right-click ratestk/rating, drag it onto the form next to the rating field, and select Create controls, as shown in the following image.
  5. Right-click the Edit box value in the Control Type column, select New control, and then select Drop down list, as shown in the following image.
  6. Click OK.
  7. Delete the rating field and header.
  8. Drag the new drop box into that space.
  9. Select the new drop box.
  10. Open the Request & Data Sources panel and the Settings panel.
  11. Drag selrate from the Variables folder into the Selection to area, as shown in the following image.

Procedure: How to Retrieve the Values

  1. Using the selrate or stack().field, edit the Maintain Data code to collect the value from the drop box, as shown in the following image. This works for drop boxes, list boxes, and radio buttons.
  2. Save the code and run the application.

    The output is:

Procedure: How to Add a Grid

Using the -IWC.updateGridData("stk"); command, non-persistent Maintain Data applications can use the grid to update multiple rows and columns.

  1. Create a new HTML page.
  2. Create a new embedded Maintain Data request, using the movies data source.
  3. Add the code, as shown in the following image.
  4. Drag the form onto the canvas.
  5. Right-click stk1, drag it onto the form, and select Create controls.
  6. Leave the first five fields selected and change the Control Type to Grid, as shown in the following image.
  7. Click OK.
  8. Open the Tasks & Animations panel.
  9. Click the arrow in the Requests/Actions section, select Run Request, then select Request1, and then select Request1.Connect, as shown in the following image.
  10. Expand the Variables folder.
  11. Drag action onto the form.
  12. Open the Properties panel.
  13. Rename edit1 to action by clicking action and changing the Unique Identifier from edit1 to action, as shown in the following image.
  14. Draw a button on the form and change the text to Update.
  15. Open the Properties panel, click the lightning bolt, and double-click Click, as shown in the following image.
  16. Set the action.value to 'U', as shown in the following image.
  17. Save the code and run the application.

    The output is: