Você está na página 1de 3

Singleton

Exercise

Chapter: Context at Runtime


Theme: Singleton

At the end of this Exercise, you will be able to:


 Create a supply method for a singleton context node

1 Development Objectives
This exercise has the following objectives:
Show only the bookings in the booking table for a selected flight in the flights table.

2 Result

In this exercise, you will create a supply


method in the component controller
which fills the booking table if the
selection in the flight table changes.

1
Singleton
Exercise
Template Solution:
Web Dynpro Component: WD_05S_TABLE_2
Application: WD_05S_TABLE_2

Starting Point of this exercise:


Web Dynpro Component: ZWD_##_TABLE_1

or the template solution

Web Dynpro Component: WD_05S_TABLE_1

Group number: ## stands for the two-digit group number

3 Developing

3-1 Copy Web Dynpro Component


Copy your Web Dynpro Component ZWD_##_TABLE_1 or the template
solution WD_05S_TABLE_1 to name ZWD_##_TABLE_2.

3-2 Build Context in the component controller


Locate the Component Controller node in the project structure that is
located immediately under the component. Double click on Component
Controller to open the Custom Controller editor.
- Add a new node to the Custom Controller Context, having the
name BOOKINGTAB. Add the new node as a subnode of node
FLIGHTTAB.
- On the popup Set the value for Cardinality to 0..n, make sure that
Singleton has the valueYes, enter SBOOK in the field Dictionary
structure and press Add Attribute from structure.
- Choose fields bookid, customid, custtype, luggweight, class and
passname and press Continue.

3-3 Create the supply function for the newly created context node
BOOKINGTAB
Stay on the Context tab of the component controller and enter
BOOKINGS_READ as Supply Function for context node
BOOKINGTAB.
Double-click on the supply function BOOKINGS_READ to navigate into
the editor.

2
Singleton
Exercise
Insert the source code for doing the following:
- Get the attributes of the parent element (= node FLIGHTTAB)
- Read the appropriate bookings from database table SBOOK into an
internal table.
Hint: Use carrid, connid and fldate in the where clause.
- Bind the internal table to the context node BOOKINGTAB.

3-4 Map node BOOKINGTAB to context of OUTPUT_VIEW


Navigate to the OUTPUT_VIEW on the Context tab. Update the mapping
for context node FLIGHTTAB in the view context. (Node BOOKINGTAB
will be added to the view context)

3-5 Display table on view OUTPUT_VIEW


Navigate to the Layout tab of the OUTPUT_VIEW.
Create a third group element under the
ROOTUIELEMENTCONTAINER element. Name it GROUP_3.
Change the LayoutData property of the new group GROUP_3 to
MatrixHeadData. Change the property Text of the element Caption_4 to
booking information.
Create a table element under GROUP_3. Name it BOOKINGTAB. Create
binding for the new table to context node BOOKINGTAB.

3-6 Create Web Dynpro Application


Right mouse click on the component node and select Create -> Web
Dynpro Anwendung (Web Dynpro Application) from the context menu.
Create the application having the following attributes:
Name: (accept default)
Decription: Table 2
Accept all default settings and press Save and run your application.

3
Singleton
Exercise

Você também pode gostar