
The design of contexts is very important for the performance of large Web Dynpro ABAP applications. A large number of context nodes and attributes will reduce performance and increase memory requirement at runtime. Since a range of UI element properties provide the binding to a context attribute, the number of context attributes can exceed the number of UI elements many times over.
Primary Properties of UI Elements
The primary property is especially important for a UI element. Other properties of the UI element can be dependent on the value of the context attribute to which the primary property is bound. Provided the UI element is available, the primary property is always the same, for example:
There are a few UI elements that do not have a primary property, for example, UI-Element TabStrip.
The concept of primary properties is also used for integrating short texts from the ABAP Dictionary. You can find more information under Primary Property in the reference documentation for UI elements.
Some UI element properties can be bound directly to the context attribute of the associated primary property, which means a new context attribute does not have to be especially created. The Web Dynpro ABAP framework enables the following UI element properties to be bound in this way:
In turn, there are four properties that can be used for the attribute of a context bound to the primary property of the UI element. (The UI element property state can have required and normal states).
How the properties of a context element bound to the primary property of UI element are used is best explained in an example.
Instead of creating a separate context attribute whose value is directly dependent on the value of the context attribute bound to the primary property, the four UI element properties mentioned above can be bound directly the respective property of the context attribute bound to the primary property. For the above example, this means:
This enables the number of attributes in the context of a view to be reduced if a large number of one or more of the four properties mentioned above is used dependent on the value of the respective "primary context attribute".
Binding the Context Attribute Properties in the View Designer
The four special UI element properties can be bound together with the primary property in one step:
In this table the UI property state can be changed by selecting a binding for the context attribute property required. If this binding is not selected, the status of the UI element remains as the default Normal.
A second way of binding UI element properties to context attribute properties is to edit the binding of the individual UI element properties manually.
The dialog box for binding a context attribute contains a radio button providing two options to perform the binding:
Select a context attribute to bind to the UI element property.
First select the context attribute to whose property you want to bind the UI element property. This is usually the primary property of the UI element. Then select the context attribute property to bind.
The dialog box provides you with the option of inverting the value of the attribute or the attribute property. This means that the inverse value of the attribute property will be used at runtime.
Program Access to the Properties of Context Attributes
The attribute E_PROPERTY is defined in the interface IF_WD_CONTEXT_ELEMENT. The value of this attribute can be set dynamically using the SET_ATTRIBUTE_PROPERTY method. The method below is taken from the demo application DEMO_CONTEXT_PROP of package SWDP_DEMO. Property ReadOnly of the UI element is bound to the property of the same name belonging to the context attribute ARRTIME. Whenever the value of the system time is greater than the value of an arrival time in the table column, this value can no longer be changed.
METHOD refresh_context . DATA: lr_flightnode TYPE REF TO if_wd_context_node, lr_elem TYPE REF TO if_wd_context_element, l_restrict TYPE wdy_boolean, l_arrtime TYPE spfli-arrtime. * We set the context properties accordingly. lr_flightnode = wd_context->get_child_node( wd_this->wdctx_flights ). DO. lr_elem = lr_flightnode->get_element( sy-index ). IF lr_elem IS NOT BOUND. EXIT. ENDIF. lr_elem->get_attribute( EXPORTING name = 'ARRTIME' IMPORTING value = l_arrtime ). IF sy-uzeit >= l_arrtime. l_restrict = 'X'. ELSE. l_restrict = space. ENDIF. CALL METHOD lr_elem->set_attribute_property EXPORTING attribute_name = 'ARRTIME' property = lr_elem->e_property-read_only value = l_restrict. enddo. ENDMETHOD.