In this lesson, you create Ajax services that create the data that the process uses. You
then configure coach views to call these services.
Before you begin
The following coach views use an Ajax service to populate
one or more of its controls:
- Person CV
- Position CV
- Requisition CV
About this task
The coach views in My Hiring Sample display data to the hiring manager and to the general
manager (GM). This lesson describes how to create the data and configure the coach view controls to
display it.
This lesson uses the following concepts:
| Concept |
Description |
| Ajax services |
A service that asynchronously sends or retrieves data from a data source, such
as a database. |
Procedure
Create an Ajax service:
- Make sure that the My Hiring Sample process application is open in Process Designer.
- In the Designer library, click the plus sign next to User Interface and
select Ajax Service.
- Type Populate DepartmentList and
then click Finish. You can
now edit the Ajax service that you created.
- Set the input and output of the service:
- Select the Variables tab.
- Click Add Input. In the Name field, type
text. For the type, use the default type, which is String.
- Click Add Output. In the Name field, type
results.
- For the variable type of the output, click Select and then select the
ANY type from the list. By selecting ANY, you are setting the output to be of any type.
- Select Is List so that service
returns a list of items.
- Create the service flow:
- Click the Diagram tab and then,
from the palette, add a server script to the process diagram and rename
it to populateDepartmentList.
- In the Properties tab, select Implementation and
add the following code:
tw.local.results = new tw.object.listOf.String();
tw.local.results[0] = "Finance";
tw.local.results[1] = "Marketing";
tw.local.results[2] = "Product Development";
tw.local.results[3] = "Human Resources";
tw.local.results[4] = "Sales";
tw.local.results[5] = "Customer Service";
tw.local.results[6] = "Business Partner Service";
tw.local.results[7] = "Business Strategies";
tw.local.results.listAddSelected(0);
- In the palette, select the Sequence Flow tool icon
. Make the following connections: - Start event to the populateDepartmentList server
script
- populateDepartmentList server script to the End
event
- Save your work.
- Configure the Department stock control so that it uses
the Ajax service to get its contents.
- Open the Requisition CV coach view
and select the Department control.
- In the Configuration properties, click Select for
the selection service. Select the Populate DepartmentList Ajax
service.
- Create the other Ajax services with the information in
the following table:
| Service name |
Script in the service |
Script code |
| Populate EmploymentTypeList |
populateStatusList |
tw.local.results = new tw.object.listOf.String();
tw.local.results[0] = "Full-time";
tw.local.results[1] = "Part-time";
tw.local.results[2] = "Contract";
tw.local.results.listAddSelected(0);
|
| Populate LocationList |
populateLocationList |
tw.local.results = new tw.object.listOf.String();
tw.local.results[0] = "Atlanta";
tw.local.results[1] = "Boston";
tw.local.results[2] = "Chicago";
tw.local.results[3] = "Cincinatti";
tw.local.results[4] = "Dallas";
tw.local.results[5] = "Denver";
tw.local.results[6] = "Des Moines";
tw.local.results.listAddSelected(2);
|
| Populate PositiontypeList |
populatePositionTypeList |
tw.local.results = new tw.object.listOf.String();
tw.local.results[0] = "New";
tw.local.results[1] = "Existing";
tw.local.results.listAddSelected(0);
|
- Configure the stock controls that use a service to get
their content. The following table lists these stock controls and
the Ajax service that you select for the Selection Service configuration
option:
| Coach view |
Stock control |
Service name |
| Position CV |
Position type |
Populate PositiontypeList |
| Requisition CV |
Location |
Populate LocationList |
| Requisition CV |
Employment status |
Populate EmploymentTypeList |