Start of Content Area

Background documentation Typing Context Attributes for Data Binding  Locate the document in its SAP Library structure

 

Controller contexts are storage locations for structured data in the Web Dynpro programming model. At runtime, values or objects of different types can be stored in context attributes.

Context elements (nodes and attributes) can be defined for different purposes:

If context attributes are used for data binding, the following rule must be observed when typing them (whether statically at design time or dynamically at runtime):

 

This graphic is explained in the accompanying text

All context attributes used for data binding between the UI and context must be typed with Dictionary types.

Data binding between the UI and the context is not possible when using native Java types.

 

In addition to the reasons for this rule, this section also describes the different Dictionary types as well as their counterparts in Web Dynpro for Java. The information serves as a basis for the typing of context attributes at design time (statically using the Web Dynpro tools) and at runtime (dynamically using controller code).

Platform-Independent Typing of Context Attributes

The Dictionary provides special data types, with which you can define data binding between UI element properties and context attributes in the Web Dynpro programming model platform-independently. These data types are not mapped onto the corresponding types of the relevant platform (for example, Web Dynpro for Java in the SAP Web Application Server) until runtime.

You can thus type context attributes independently of a specific runtime type (Java type or ABAP type) at design time. At runtime, the context attributes then have the type corresponding to the underlying Dictionary type within the platform-independent controller implementation. This runtime type is also used in the generated context APIs.

 

 

This graphic is explained in the accompanying text

The figure above shows the connection between the design time and runtime type of a context attribute. To bind the visibility property of an input field to a corresponding context attribute FieldVisibility in the view layout, it must be typed with the Dictionary type com.sap.ide.webdynpro.uielementdefinitions.Visibility. If the application is started in Web Dynpro for Java, the FieldVisibility attribute is stored in the context as value of the Java type com.sap.tc.webdynpro.progmodel.WDVisibility.

 

Dictionary Types

Dictionary types can be divided into the following categories:

       1.      Predefined types: By default, the Dictionary already contains predefined or built-in types – for example, string, integer, or time – in the Dictionary package com.sap.dictionary.*. Furthermore, the package com.sap.dictionary.predefined.objecttypes.* contains types, with which context attributes can be stored object-based instead of value-based (for example, as java.lang.Integer object instead of int value).

       2.      Types for Web Dynpro UI elements: Web Dynpro expands the Dictionary to include types required for specific UI element properties. In particular, these are the various enumeration types like Visibility as well as different Design or Size types.

       3.      User-defined local types: In the local Dictionary, application developers can, when necessary, define their own Dictionary types based on other Dictionary types.

       4.      Types in logical Adaptive RFC models: When an Adaptive RFC model is imported, the used ABAP Dictionary types are stored as corresponding data types in the logical Dictionary so that they can then be used for data binding purposes.

The assignments of the predefined and Web Dynpro UI-specific Dictionary types to the corresponding Java types are shown in the tables in the next section.

Typing Context Attributes for Data Binding at Design Time

In the standard case, you will define a context attribute at design time so that you can then bind a specific UI element property to it. Depending on the UI element property, the context attribute type must be a suitable predefined Dictionary type (selection list for context attribute property type) or any other Dictionary type (Dictionary Simple Type – Dictionaries – <Logical or Local Dictionary> – <Package Name> – Dictionary Type).

..

       1.      In the SAP NetWeaver help, open the UI element description.

       2.      Find the type of the relevant property in the UI element description.

       3.      The appropriate Dictionary type for the corresponding context attribute matches the Java type, with the exception of the prefix WD. 

This graphic is explained in the accompanying text

More information about the definition of context attribute types is available in the section Defining Controller Contexts.

Typing Context Attributes for Data Binding at Runtime

When dynamically adding context attributes to a context node for purposes of data binding, note that in this case you must also use a suitable Dictionary type and not the corresponding Java type for the typing with the methods addAttribute() and addValueAttribute() in the IWDNodeInfo API.

·        Predefined, Web Dynpro UI-specific, and user-defined Dictionary types all have the prefix ddic:.

This graphic is explained in the accompanying text

wdContext.getNodeInfo()
.addAttribute(
  "Visibility",
  "
ddic:com.sap.ide.webdynpro.uielementdefinitions.Visbility
")

·        Logical Dictionary types from Adaptive RFC models have the prefix extern:.

This graphic is explained in the accompanying text

Note that no new Dictionary types can be created at runtime. However, it is possible to carry out dynamic type modifications for individual context attributes using the IWDAttributeInfo API. Calling the method IWDAttributeInfo.getModifiableSimpleType() gives you access to the com.sap.dictionary.runtime.IsimpleTypeModifiable API, with which you can alter the type information of a context attribute (for example, add new key/display text pairs or set the field label).  In all cases, the changes are based on the Dictionary type with which the context attribute was statically or dynamically typed.
An example of this is described under Including an Extended Value Selector.   

 

 

 

End of Content Area