Define the second drill-down application—SSCAEmployee. This application displays employee information. The application uses an @OP tag to dynamically select rows from the database to replace the Emp Name parameter.
Defining the SSCAEmployee application
From Mobile Web Studio, select Applications from the Build menu in the left pane, select New under Application Manager, and click the New button to launch Application Builder.
Click the down arrow to the right of the Add button, and select Database Element.
In the Database Elements Definition window, enter JDBC connection information needed for the application to access a database and extract specific database information.
The values in the following example assume that sampledb has been started, and is accessible on port 4747.
Click the JDBC URL option button.
Complete these options:
Username – enter dba
,
which is the user name used to access the database.
Password – enter SQL
,
which is the password used to access the database.
JDBC Connect URL – enter the URL used by JDBC to connect to the database:
jdbc:sybase:Tds:localhost:4747?ServiceName=sampledb
JDBC driver – enter the JDBC driver used to connect to the database, in this case:
com.sybase.jdbc2.jdbc.SybDriver
SQL Query String – enter the following SQL code to select employees from sampledb. Cut and paste this code from the HTML version of this guide:
select 1 as ID, 'Employee ID' as Item, convert(varchar(255), emp_id) as Data from employee e where '@OP["Emp Name"="Fran Whitney"]' = emp_fname + ' ' + emp_lname
UNION
select 2 as ID, 'Employee Name', emp_fname + ' ' + emp_lname from employee e where '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
UNION
select 3 as ID, 'Manager Name', e2.emp_fname + ' ' + e2.emp_lname from employee e, employee e2 where e2.emp_id = e.manager_id and '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
UNION
select 4 as ID, 'Dept Name', d.dept_name from employee e, department d where e.dept_id = d.dept_id and '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
UNION
select 5 as ID, 'Birthdate', convert(varchar(255), birth_date) from employee e where '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
order by 1
This includes the @OP tag, Emp Name, which sets the default value to Fran Whitney. In a later step, you will assign the default on the Parameter page to complete the process.
When you create an application with input parameters,
you must define a default value to register as click-across event listeners.
Click Preview. A three-column table showing ID, Item, and Data displays in the Preview panel.
ID |
Item |
Data |
---|---|---|
1 |
Employee ID |
102 |
2 |
Employee Name |
Fran Whitney |
3 |
Manager Name |
David Scott |
4 |
Dept Name |
R & D |
5 |
Birthdate |
Jun 05 1959 12:00AM |
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,” accept the default, 1
,
then click Next.
In the Filter window, define a filter that excludes column (field) 1.
In the left-most drop-down list, select “Exclude field(s).”
The second drop-down list is set to “number.”
In the text box, enter 1
to exclude column
1.
Click Add. In Preview, field 1 is highlighted in a contrasting color, and a new rule is added under Current Filter Rules.
Click Next.
When the Configure Parameters window displays, specify the @OP tag as an application parameter, and define Fran Whitney as the default value for Emp Name. Co. Select the Variable option to the left of Emp Name. The variable moves to the bottom of the list. Accept these defaults:
Display Name – Emp Name.
Default Value – Fran Whitney.
Type – Text Field.
Click Next.
The Window Preview displays. In Element Name, enter SSCAEmployee
. Under
Window Preview, notice the grid showing Item and Data.
Click Finish.
When you return to the Application Builder window, click Save.
In the Finish window, accept the defaults, and click Finish to save the application.
Click OK in the confirmation pop-up window.
Click Close to exit the Application Builder.
When you return to the Mobile Web Studio main window, select New from the Application Builder Status menu. The SSCAEmployee application displays in the detail pane.
Right-click the SSCAEmployee application in the detail pane, and select Approval Status | Approved.
Click OK to confirm.
Select Approved from the Application Manager Status menu. You see the SSCAEmployee application in the detail pane.