Skip to Content

We can set some application specific properties through a properties file. This properties file can be in the deployable object or in a deployable object part( Application, component, component interface) . When an application with a property file is being deployed it gets deployed as property sheets in the configuuration adapter.

Accessing the Deployable Object property file

If you want to use the file as part of the deployable object then the file can be imported into the src/configurations folder of the project. These property can be accessed in the code as follows.

The properties file.
image

The file stored in folder.
image

IWDDeployableObject depl=wdComponentAPI.getDeployableObjectPart().getDeployableObject();
try{
IWDConfiguration config=WDConfiguration.getConfigurationByName(depl,”my_config”);
String prop=”name”;
String value=config.getStringEntry(prop);
wdComponentAPI.getMessageManager().reportSuccess(prop +” = “+value);
}catch(Exception e){
wdComponentAPI.getMessageManager().reportSuccess(e.toString());
}

Accessing the Deployable Object property file

The following example code explains how to access the properties file from the deployable object part( Here Application has been used as a part).

image

IWDDeployableObject depl=WDDeployableObject.getDeployableObject(wdComponentAPI.getDeployableObjectPart().getDeployableObjectName());
WDDeployableObjectPart[] depPart=depl.getParts(WDDeployableObjectPartType.APPLICATION);
try{
IWDConfiguration config=WDConfiguration.getConfigurationByName(depPart[0],”my_config”);
String prop=”name”;
String value=config.getStringEntry(prop);
wdComponentAPI.getMessageManager().reportSuccess(prop +” = “+value);
}catch(Exception e){
wdComponentAPI.getMessageManager().reportSuccess(e.toString());
}

Accessing the System Configuration properties

Many a time it becomes necessary to access the system configurations in the code. The system configuration is a part of the sap.com/tc~wd~dispwda.ear file that is deployed with the WebDynpro.wda archive file.

The below examples shows how to access the values of the basic settings in the default.properties file.

IWDDeployableObject depl=WDDeployableObject.getDeployableObject(“sap.com/tc~wd~dispwda”);
try{
IWDConfiguration config=WDConfiguration.getConfigurationByName(depl,”default”);
String[] prpEntry=config.getAllKeys();

for(int i=0;i < prpEntry.length;i++){
String prop=prpEntry[i];
String value=config.getStringEntry(prop);
wdComponentAPI.getMessageManager().reportSuccess(prop+” = “+ value);
}
}catch(Exception e){
wdComponentAPI.getMessageManager().reportSuccess(e.toString());
}

Result

Reading an application specific property file.
image

Reading a system configuration property file.
image

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Sonal Mangla
    Hi Noufal
    Great work !!
    I was trying to access the system configuration porperties exactly in the same way as you have stated but i am getting the following error

    com.sap.tc.webdynpro.services.sal.config.api.WDConfigurationNotFoundException: Configuration not found: webdynpro/test.com/test/default.

    Is default.properties file is present in all webdynpeo applications or do we have to make some extra configuration for the same?

    Regards
    Sonal

    (0) 

Leave a Reply