cancel
Showing results for 
Search instead for 
Did you mean: 

Work with Directory

Former Member
0 Kudos

Hello,

Ich have a following question:

My WebDynpro-Application works with some xml files, which have to be placed into WebDynpro-Directory. Where can i create a directory for my xml documents? And how can i get a path to this directory in my WebDynpro Application?

With best regards

Michael Belenki

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Put your XML file in the resource folder src/mimes/Components/<component> and use


WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart())

to get the resource path.

Former Member
0 Kudos

Hello,

Thanks. But i have the problem that i cannot work with file, because the path is relative.

WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart())

returns something like

this .\temp\webdynpro\web\localhost\myWebDynproApplication\packagename\Component\myfile.xml

And now i would like to create File-object

File myFile = new File(path).

How can i get a full path to my xml document?

With best regards

Michael Belenki

Former Member
0 Kudos

Hi Michael,

this shouldn't be a problem, since the "." is just a placeholder for the current directory. If you want to get the absolute path, then

File curDir = new File(".");
String absPath = curDir.getAbsolutePath();

is one way to find it out.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan,

Yes, you are right, this was sadly not the problem.

With the help of 'WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart() + File.separator + "myfile.xml")' i get a path, which doesn't exist: path: ".\temp\webdynpro\web\local\WebDynpro_MyProject\com.sap.tc.webdynpro.myproject.mycomp\Component\myfile.xml"

Right path is:

C:\usr\sap\J2E\JC00\j2ee\cluster\server0\temp\webdynpro\web\local\WebDynpro_MyProject\Components\com.sap.tc.webdynpro.myproject.mycomp\myfile.xml

But how can i get a right path and is it bug?

with best regards

Michael

Former Member
0 Kudos

Hi Michael,

no, it's not a bug, the reason is, how you make the call. Since you concat wdComponentAPI.getDeployableObjectPart() + File.separator + "myfile.xml", you really call WDUrlGenerator.getResourcePath(String), which results in ".\temp\webdynpro\web\<objectName>". <objectName> is the fully qualified name of the deployable object part appended with the file in your call.

Please use the following instead:

try {
  String url = WDURLGenerator.getResourcePath(
    wdComponentAPI.getDeployableObjectPart(), 
    "myfile.xml"
    );
  wdComponentAPI.getMessageManager().reportSuccess(url);
} catch (WDAliasResolvingException e) {
  wdComponentAPI.getMessageManager().reportException(
    e.getMessage(), true
  );
}

Hope that helps.

Best regards

Stefan

Answers (0)