• No se han encontrado resultados

7.  EL MARCO REGULATORIO DE LAS ENERGIAS RENOVABLES

8.5  VALORACIÓN PARA EL CASO ESPAÑOL

8.5.2. Valoración de las opciones del Real Decreto 661/2007

Exercise Objectives

After completing this exercise, you will be able to:

• Send windows defined in same component as modal dialog boxes.

• Define buttons in a modal dialog box and handle clicking these buttons.

Business Example

The user of your application should be able to display bookings related to a selected flight. The bookings should be displayed in a modal dialog box.

Template Component: NET311_API_S Solution Component: NET311_WINDOW_S

Task 1:

If you have finished the previous exercise, you can skip this task. Then, all changes can be implemented in the component you have created in your last exercise.

If you have not finished your last exercise, you can start with a copy of the template component. In this case, copy the template component and name the copy ZNET311_WINDOW_##. Assign this component to your package ZNET311_##.

Create an application having the same name as your component and assign the application to your package, too.

1. Copy the template component.

2. Create an application to access your component.

Task 2:

The table displaying the flights allows to select a single line. Marking this line triggers a round trip. The component controller has to be changed in a way, that bookings related to the selected flights are read and stored in the controller context, automatically.

1. In the component controller context, define a new node BOOKINGS of type SBOOK as a sub node of the node FLIGHTS. The node BOOKINGS has to contain the attributes BOOKID, CUSTOMID, CUSTTYPE, SMOKER, CLASS, FORCURAM, FORCURKEY, and ORDER_DATE.

2. Assign a supply function (name: GET_BOOKINGS( )) to the node

3. Implement the supply function. Bookings for a given flight should be read using the static method READ_BOOKINGS( ) of class CL_NET310_FLIGHTMODEL.

Task 3:

The bookings are to be displayed by a separate view embedded in a new window.

This window has to be displayed as a modal dialog box.

1. Create a new view (name: POPUP_VIEW). Copy and map the context node BOOKINGS defined in the component controller to the context of the new view.

2. Use the Web Dynpro Code Wizard to create a table View UI element displaying the bookings. Restrict the number of lines displayed by the table to 10. Hide the column to select table lines.

3. Create a new window (POPUP_WINDOW). Embed the view POPUP_VIEW in this window.

Task 4:

The window POPUP_WINDOW has to be displayed when the user selects a flight. Thus create an action in the view MAIN_VIEW. Assign this action to the event onLeadSelect of the table displaying the flights. In the related action handler method create and open a modal dialog box for displaying the window POPUP_WINDOW.

Because the reference to the created popup is accessed in different methods of different controllers, this reference should be stored as a public attribute of the component controller.

1. Create a public attribute (name: GR_WINDOW) of reference type IF_WD_WINDOW in the component controller of your component.

2. Create a new action (name: DISP_DETAILS) in view MAIN_VIEW. Assign this action to the event onLeadSelect of the table displaying the flights.

3. Implement the action handler method ONACTIONDISP_DETAILS( ):

- Get a text displayed as the title of the dialog box from the assistance class.

Get the reference to the window manager.

Call the appropriate method for sending a window of the same component as a modal dialog box.

Store the reference to the created popup in the corresponding attribute of the component controller.

Finally, display the modal dialog box.

Continued on next page

The following settings should be used for the dialog box:

- The OK button should be displayed exclusively. This button should be defined as the default button.

- The Close button of the window (right upper corner) should not be visible.

- Pressing the OK button should not close the modal dialog box automatically.

- An extra image left of the tableView UI element (indicating the severity of the information displayed in the popup) is not desired.

- Use constants of the interface IF_WD_WINDOW to evaluate the parameters of this method whenever possible.

Task 5:

Up to now, pressing the OK button in the modal dialog box is not related to special code. To change this, the following steps are necessary:

In the view POPUP_VIEW a new action has to be defined. This action has to be assigned to the event “pressing the OK button”. Finally, the action handler method has to be implemented: If the OK button is pressed, the dialog box has to be closed.

The references to the view controller API of view POPUP_VIEW is accessed multiple times. Thus it is a good idea to create a controller attribute in the view POPUP_VIEW to store this reference. The value of this attribute should be determined in the method WDDOINIT( ) of the view controller.

1. Create the action OK_BUTTON_ACTION in the view POPUP_VIEW.

2. Create the method REGISTER_BUTTONS( ) in the view POPUP_VIEW.

3. Create a controller attribute in the view POPUP_VIEW. At runtime, this attribute (name: GR_VIEW_API) should contain the reference to the view controller API (interface IF_WD_VIEW CONTROLLER).

4. Set the value of the controller attribute GR_VIEW_API in the method WDDOINIT( ) of view POPUP_VIEW.

5. Call the method REGISTER_BUTTONS( ) from the method WDDOINIT(

) of view POPUP_VIEW.

6. Implement the method REGISTER_BUTTONS( ):

Register the action OK_BUTTON_ACTION for the event “pressing the OK button”.

7. Implement the handler method of action OK_BUTTON_ACTION:

Solution 3: Dialog boxes

Task 1:

If you have finished the previous exercise, you can skip this task. Then, all changes can be implemented in the component you have created in your last exercise.

If you have not finished your last exercise, you can start with a copy of the template component. In this case, copy the template component and name the copy ZNET311_WINDOW_##. Assign this component to your package ZNET311_##.

Create an application having the same name as your component and assign the application to your package, too.

1. Copy the template component.

a) Display the template component in the object tree. Clicking on the component with the right mouse button will open the component's context menu. Choose Copy.... Enter the name of the component to be created. Press Continue.

b) Adapt the description of the new component.

2. Create an application to access your component.

a) An application having the same name as the component can be created from the context menu of the component.

Task 2:

The table displaying the flights allows to select a single line. Marking this line triggers a round trip. The component controller has to be changed in a way, that bookings related to the selected flights are read and stored in the controller context, automatically.

1. In the component controller context, define a new node BOOKINGS of type SBOOK as a sub node of the node FLIGHTS. The node BOOKINGS has to contain the attributes BOOKID, CUSTOMID, CUSTTYPE, SMOKER, CLASS, FORCURAM, FORCURKEY, and ORDER_DATE.

a) Edit the component controller. Select the tab Context. Right

mouse-click on the node FLIGHTS. In the context menu, choose Create

→ Node.

b) Enter name and type. Change the Cardinality property to (0:n).

c) Press the button Add Attribute from Structure. Select the structure fields listed above and press Continue.

Continued on next page

2. Assign a supply function (name: GET_BOOKINGS( )) to the node BOOKINGS.

a) Enter the method's name in the related property field of the context node and press Enter.

3. Implement the supply function. Bookings for a given flight should be read using the static method READ_BOOKINGS( ) of class CL_NET310_FLIGHTMODEL.

a) Source code see below.

Task 3:

The bookings are to be displayed by a separate view embedded in a new window.

This window has to be displayed as a modal dialog box.

1. Create a new view (name: POPUP_VIEW). Copy and map the context node BOOKINGS defined in the component controller to the context of the new view.

a) Proceed as described in exercises you have solved before. Do not map the node FLIGHTS, but only the sub node BOOKINGS.

2. Use the Web Dynpro Code Wizard to create a table View UI element displaying the bookings. Restrict the number of lines displayed by the table to 10. Hide the column to select table lines.

a) Proceed as described in exercises you have solved before. The number of lines displayed by the table is defined by the property visibleRowCount. Setting the property selectionMode to none will hide the mark column.

3. Create a new window (POPUP_WINDOW). Embed the view POPUP_VIEW in this window.

a) Proceed as described in exercises you have solved before.

Task 4:

The window POPUP_WINDOW has to be displayed when the user selects a flight. Thus create an action in the view MAIN_VIEW. Assign this action to the event onLeadSelect of the table displaying the flights. In the related action handler method create and open a modal dialog box for displaying the window POPUP_WINDOW.

Because the reference to the created popup is accessed in different methods of different controllers, this reference should be stored as a public attribute of the component controller.

1. Create a public attribute (name: GR_WINDOW) of reference type IF_WD_WINDOW in the component controller of your component.

a) Edit the component controller. Select the Attributes tab. Enter name and type of the attribute in the fields Attribute and Associated Type, respectively. Mark the property RefTo.

2. Create a new action (name: DISP_DETAILS) in view MAIN_VIEW. Assign this action to the event onLeadSelect of the table displaying the flights.

a) Edit the properties of the tableView UI element of view MAIN_VIEW.

Create the action and assign it to the event onLeadSelect of the tableView UI element in one step. This is done by clicking the Create button right of the property onLeadSelect. In the dialog that pops up, enter the action name in the field with the label Action.

3. Implement the action handler method ONACTIONDISP_DETAILS( ):

- Get a text displayed as the title of the dialog box from the assistance class.

Get the reference to the window manager.

Call the appropriate method for sending a window of the same component as a modal dialog box.

Store the reference to the created popup in the corresponding attribute of the component controller.

Finally, display the modal dialog box.

The following settings should be used for the dialog box:

- The OK button should be displayed exclusively. This button should be defined as the default button.

- The Close button of the window (right upper corner) should not be visible.

- Pressing the OK button should not close the modal dialog box automatically.

- An extra image left of the tableView UI element (indicating the severity of the information displayed in the popup) is not desired.

Continued on next page

- Use constants of the interface IF_WD_WINDOW to evaluate the parameters of this method whenever possible.

a) The text id you should use is 002.

The correct method to create this kind of window is CREATE_WINDOW( ).

b) Source code see below.

Task 5:

Up to now, pressing the OK button in the modal dialog box is not related to special code. To change this, the following steps are necessary:

In the view POPUP_VIEW a new action has to be defined. This action has to be assigned to the event “pressing the OK button”. Finally, the action handler method has to be implemented: If the OK button is pressed, the dialog box has to be closed.

The references to the view controller API of view POPUP_VIEW is accessed multiple times. Thus it is a good idea to create a controller attribute in the view POPUP_VIEW to store this reference. The value of this attribute should be determined in the method WDDOINIT( ) of the view controller.

1. Create the action OK_BUTTON_ACTION in the view POPUP_VIEW.

a) Enter the action name in the field Action on tab Actions.

2. Create the method REGISTER_BUTTONS( ) in the view POPUP_VIEW.

a) Proceed as described in exercises you have solved before.

3. Create a controller attribute in the view POPUP_VIEW. At runtime, this attribute (name: GR_VIEW_API) should contain the reference to the view controller API (interface IF_WD_VIEW CONTROLLER).

a) Select the Attributes tab. Enter name and type of the attribute in the fields Attribute and Associated Type, respectively. Mark the property RefTo.

4. Set the value of the controller attribute GR_VIEW_API in the method WDDOINIT( ) of view POPUP_VIEW.

a) Source code see below.

5. Call the method REGISTER_BUTTONS( ) from the method WDDOINIT(

) of view POPUP_VIEW.

a) Source code see below.

Register the action OK_BUTTON_ACTION for the event “pressing the OK button”.

a) Source code see below.

7. Implement the handler method of action OK_BUTTON_ACTION:

Check the name of the user event by checking the value of the public attribute WDEVENT->NAME. Close the modal dialog box, if this value corresponds to the value expected for the OK button (value: ON_OK).

a) Source code see below.

Result