This section shows how to create the customer list application. You will create another database element using the same sampledb connection, but with a different SQL query. You will also link the customer list to the update application, and establish a listener for the cust_id field.
Creating the customer list
In Mobile Web Studio, select Applications in the left pane, New in the Application Builder Status menu, and click the New button.
In Application Builder, click the down arrow to the right of Add, and select Database Element.
On the Database Element Definition window, define the database element:
Make sure the Connection Cache option is selected.
In Conn Cache Name, select sampledb from the drop-down list.
In SQL query string, enter this query:
set rowcount 10 select c.fname as customer_fname , c.lname as customer_lname, si.id, si.prod_id, p.name, si.quantity from customer c, sales_order s, sales_order_items si, product p where c.id =@OP["cust_id"="101"] and s.id = si.id and si.prod_id =p.id and s.region ='@OP["region"="Western"]' set rowcount 0
Click Preview to make sure these columns are included: customer_fname, customer_lname, id, prod_id, name, and quantity.
Click Next. The Define window displays.
Use the Define window to identify record 1 as the header row. In the Define Record Layout section, click “Records contain labels.”
The “Labels are displayed in Record” option
displays. Accept the default, 1
,
and click Next.
In the Filter window, click Next. The Configure Parameters window displays.
On the Configure Parameters window, make these modifications (accept the defaults for all others):
Region – click the Variable box and make these changes:
Default Value – enter Western,Central
(no
spaces).
Type – choose Select from the drop-down list, and click Add. The Edit Default Value window displays.
In the first row, Western displays for both Display Name and Value.
In the second row, Central displays for both Display Name and Value.
Click OK to accept the values, and close the window.
Personalize – choose “database table” from the drop-down list.
Key – region
displays
as the personalization key (you created the region key in “Creating a personalization key”). If a different
key displays, select “region” from the drop-down
list.
Cust_id – click the Variable box and accept the defaults:
Default Value – accept 101
as
the default value for this parameter.
Type – accept Text Field from the drop-down list.
Click Next. The Window Preview window displays.
In Element Name, enter customerOrder
(no
spaces), and click Finish.
In Application Builder, click Save.
In the Finish window, accept the defaults, and click Finish to save the application.
Click OK to confirm.
Click Close to exit the Application Builder.
When you return to the Mobile Web Studio main window, select New from the Application Manager Status menu. The customerOrder application displays in the detail pane.
In Mobile Web Studio, right-click the customerOrder application in the detail pane, and select Approval Status | Approved.
Click OK to confirm.
Select Approved from the Application Manager Status menu. You see your newly approved customerOrder application in the detail pane.
Optionally, select customerOrder, and click Preview.
In region, select Central from the drop-down list and click OK. The first customer ID value changes from 2020 to 2006.
In cust_id, enter 102 and click OK. The customer
name changes from Michaels to Beth. (Other customer IDs include 103
, 104
,
and so forth).