cancel
Showing results for 
Search instead for 
Did you mean: 

Resource URL or Relative path.

Former Member
0 Kudos

Hi ,

In my webdynpro view i have a LinkToUrl button.I want to supply a URL to this button property Reference.

I have a HTML file in KM under documents/mydocs/test.html

my coding looks like this

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);

IResourceContext resourceContext = new ResourceContext(ep5User);

IResourceFactory resourceFactory = ResourceFactory.getInstance();

RID pathRID = RID.getRID(wdContext.currentContextElement().getPath());

IResource resource = resourceFactory.getResource(pathRID, resourceContext);

after this coding,i dont know how to get the URL or full path.I have checked getTargetUrl but it returns null.

Can someone help me with this. ??

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The complete path is

"http://server:port/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docsdocuments/mydocs/test.html"

You can also omit the "http://server:port" part.

You can get all the documents inside the folder by the following

IResource resource = resourceFactory.getResource(ridpath,

resourceContext);

// cast the object to a Collection

ICollection collection = (ICollection) resource;

// get the Collection's children

IResourceList resourceList = collection.getChildren();

// and finally get an iterator to walk through the set of children

IResourceListIterator resourceListIterator = resourceList.listIterator();

while (resourceListIterator.hasNext()) {

// … and create a new context element for each of them

IResource tempResource = resourceListIterator.next();

fileName = tempResource.getName();

}

You can refer this weblog

free to ask more

award points. if useful.

Geogi

Former Member
0 Kudos

Thanks Geogi,

I have this info already.i have also gont through this blogs but these are not helping in my case.

Former Member
0 Kudos

Hi Baskaran

Using this you can provide the link and clicking the link document get opened

Regards

Geogi

Former Member
0 Kudos

Hi

This is the code for opening the document on clicking the link.The body of the function is below.

IWDWindow newwindow = wdComponentAPI.getWindowManager().createExternalWindow( "http://<servername>:<port>/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs"wdContext.currentContextElement().getPath()"/"+name,"from km repository",false);

newwindow.open();

(Here Path=/documents/mydocs and variable name=test.html)

Regards

Geogi

Former Member
0 Kudos

Please don't hardcode this stuff. Use IURLGeneratorService instead.

Former Member
0 Kudos

Hi Julian,

Can you please give me some code snipet for this

Former Member
0 Kudos

Try something like:


      IURLGeneratorService generator = (IURLGeneratorService)ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);
      IUriReference target = generator.getRelativeUri(PathKey.CONTENT_ACCESS_PATH).appendPath(res.getRID().toExternalForm());

Former Member
0 Kudos

Thanks Julian.

This is what i was looking for.It works the way i wanted,you are Great.

Answers (0)