Show TOC Start of Content Area

Process documentation Configuration Service Locate the document in its SAP Library structure

Purpose

The configuration service can be used for accessing configuration files that are deployed with a Web Dynpro application. The configuration data is available in the form of name/value pairs in the properties files. The IWDConfiguration interface provides methods for accessing this configuration data as typed objects.

Web Dynpro provides several configuration properties files. More information: Structure linkWeb Dynpro System Configuration, Configuring the Web Dynpro Application.

A Web Dynpro application can define its own configuration properties files This can be done either at the level of a deployable object or at the level of a deployable object part. The IWDConfiguration interface also provides methods to access the properties files that you have defined and to use the properties files to read data.

Note

You can define application-specific properties files yourself. To do this, you create a properties file that contains the corresponding name/value pairs using an editor of your choice. You then import this file into the corresponding directory structure in the Package Explorer:

      If you want to use the properties file at the level of the deployable object (interface IWDDeployableObject), you have to import the file into directory /src/configurations in your Web Dynpro project.

      If you want to use the properties file at the level of the deployable object parts (interface IWDDeployableObjectPart), you must import the file into directory /src/configurations/<type of deployable object parts>/<name of deployable object parts> in your Web Dynpro project.

Types for deployable object parts are Application, Component, or ComponentInterface. You can find a complete list of types in the enumeration class com.sap.tc.webdynpro.services.sal.deployment.WDDeployableObjectPartType. When you deploy a Web Dynpro application that contains properties files either at the level of the deployable objects or at the level of the deployable object part, these property files are deployed as properties sheets in the Configuration Adapter of the Java Engine. To change these properties files, you can use the Configuration Adapter service of the Visual Administrator of the Java Engine. You then do not need to modify the source text or perform another deployment.

Note

Note that redeployment of the development component overwrites all the changes made to the properties files using the Configuration Adapter.

Example

The following source code describes how to access the data of configuration properties files:

 

// All used classes are contained in package

// com.sap.tc.webdynpro.services.sal.config.api or

// com.sap.tc.webdynpro.services.sal.deployment.api.

 

// get the deployable object part for application

// “com.sap.test.CICApplication” of the deployable

// object “SPICe” using the WDConfiguration factory class

DeployableObject spiceDeplObj = WDDeployableObject.getDeployableObject(“SPICe”);

WDDeployableObjectPart[] applParts =

    spiceDeplObj.getParts(WDDeployableObjectPartType.APPLICATION);

WDDeployableObjectPart cicPart = null;

for ( int i=0; i<allParts.length; i++) {

    if ( allParts[i].getName().equals(“com.sap.test.CICApplication”) ) {

       cicPart = allParts[i];

       break; 

    }

}

// Note: You can access the deployable object part of the application you are

//currently in also by using the wdComponentAPI instance variable that

// is available in each generated Web Dynpro view:

WDDeployableObjectPart currentAppPart = wdComponentAPI.getApplication().getDeployableObjectPart();

 

// get the “CICApplication.properties” that belong to the deployable oject part

//named “com.sap.test.CICApplication”

IWDConfiguration cicConfig = WDConfiguration.getConfiguration(cicPart);

 

// alternatively, you can use the following call to access the property file

//named "CICApplication" under the deployable object part

//"com.sap.test.CICApplication"; you have to use this API in case you like

//to access property files which have a name not equal

//to the unqualified name of the deployable object part

IWDConfiguration cicConfig2 = WDConfiguration.getConfigurationByName(cicPart, "CICApplication");

 

// get the integer value of the property with name “prop1”

int prop1 = cicConfig.getIntEntry(“prop1”);

 

// get the boolean value of the property with name “prop2”,

// set a default value in case “prop2” is not contained in the

// properties

boolean prop2 = cicConfig.getBooleanEntry(“prop2”, false);

 

// get the configuration “my_config.properties” in the scope

// of the application part using the WDConfiguration factory class

IWDConfiguration myConfig =

    WDConfiguration.getConfigurationByName(cicPart, “my_config.properties”); 

 

// get the “default.properties” configuration belonging to the

// deployable object

IWDConfiguration spiceConfig = 

    WDConfiguration.getConfiguration(cicPart.getDeployableObject);

 

 

End of Content Area