Start of Content Area

Background documentation Properties of Context Attributes  Locate the document in its SAP Library structure

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.

 

Note To prevent the implementation of large numbers of context attributes, as an alternative, the properties of the context attribute to which the primary property of the UI element is bound can be used to bind the UI element properties.

 
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:

      The property value for the UI element InputField

      The property Text for the UI element TextView

      The property checked for the UI element CheckBox

 

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:

        enabled

        readOnly

        state

        visible

 

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.

 

Example Arrival times of flights are listed in a table column. Provided the plane has not yet landed, the arrival time is to be changeable to allow for delays. Once the plane has landed, the value is no longer to be changeable. To enable this, the UI element property readOnly must be bound in the context. The property value is the primary property of the UI element. The value of the property readOnly is dependent on the value of the context attribute to which the property value is bound, since this provides the arrival time of the each flight. 

 

This graphic is explained in the accompanying text

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:

 

Example The changeability of the individual table columns can be controlled at runtime by binding the UI element property readOnly to the attribute property of the same name belonging to the context element ARR_TIME.

 

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:

      If you click on the binding button of the property of your selected UI element, the dialog box providing the context available for this view opens, together with its binding elements. If this property is the primary property of the UI element (for instance, the value property of an input field), the Context Attribute button will appear beneath the context structure.  Property Bindings

      Select one of the context attributes to bind to the primary property.

      To bind one or more of the four special UI element properties, open a second dialog box using the button Context Attr. Property Bindings

      The four properties of the selected context attribute to bind to the properties of the same name of the UI element are displayed in a table.

Caution 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.

      Choose the binding button of one of the four UI element properties enabled, readOnly, state or visible.

The dialog box for binding a context attribute contains a radio button providing two options to perform the binding:

      Bind directly to the selected attribute:

Select a context attribute to bind to the UI element property.

      Bind to a property of the selected attribute:

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.

 

 

 

End of Content Area