cancel
Showing results for 
Search instead for 
Did you mean: 

KM with WebDynpro

sureshmandalapu6
Active Contributor
0 Kudos

Hi Experts,

I would like to display a picture in WebDynpro Java application. The picture is there in the KM documents folder. How can i take that picture and what is the code reqired.

Thanks in advance

Suresh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Easiest option is use the link from the KM .

Regards

Ayyapparaj

sureshmandalapu6
Active Contributor
0 Kudos

Hi Ayyapparaj,

I got your point, but ! it is not the static image and it keep changing the image dynamically. So ! I need to get the corresponding path and then display it as dynamic.

Thanks

Suresh

Former Member
0 Kudos

<code>

try

{

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

IUser sapUser = wdClientUser.getSAPUser();

com.sapportals.portal.security.usermanagement.IUser ep5User =

WPUMFactory.getUserFactory().getEP5User(sapUser);

// Getting the Resourceu2026u2026u2026

IResourceContext resourseContext = new ResourceContext(ep5User);

IResourceFactory resourseFactory = ResourceFactory.getInstance();

String path="/documents/Images/photo.jpg";

RID pathRIDimg = RID.getRID(path);

com.sapportals.wcm.repository.IResource resourceimg =

resourseFactory.getResource(pathRIDimg, resourseContext);

// Reading the image fileu2026u2026

BufferedInputStream bufIn =

new BufferedInputStream(resourceimg.getContent().getInputStream());

byte[] imagebyte = new byte[bufIn.available()];

bufIn.read(imagebyte);

// Mapping the image as a WebResourceu2026.

IWDWebResource webResource = WDWebResource.getWebResource(

imagebyte,

WDWebResourceType.JPG_IMAGE);

wdContext.currentContextElement().setImage(webResource.getURL());

}

catch (Exception e)

{

e.printStackTrace();

}

Here I have used Image UI as static, you can do it dynamic.

Context attribute "Image" is of type string. map the context to source property of Image UI.

Hope this helps

sureshmandalapu6
Active Contributor
0 Kudos

Hi alok parija,

Thanks for your code. Since it is single image , it will work fine. but I need to change the image dynamically whenever user selects another Staff number. all staff images are stored in documents folder. I have to get corresponding staff number image dynamically. How can i get like that ?

thanks in advace

Suresh

Former Member
0 Kudos

You can do one thing. Save the photos with name as staff number. When the staff changes the number save the value in a context attribute and use this attribute as part of ur path of KM.

String path = "/documents/Images/" + staffnum + ".jpg";

In this this way u can get the image for corresponding staff number dynamically.

sureshmandalapu6
Active Contributor
0 Kudos

Hi,

I am refering the below blog to display images from KM.

When I Import the below API in the class, I am getting "Depricated" warning.

import com.sapportals.portal.security.usermanagement.IUserFactory;

Any substitute for this api in NWDS 7.0 version.

Thanks

Suresh

Answers (1)

Answers (1)

sureshmandalapu6
Active Contributor
0 Kudos

Hi,

The below line of code shows that the REsourceFactory .getInstance() is not there in ResourseFactory.

IResourceFactory resourseFactory = ResourceFactory.getInstance();

Thanks

Suresh

former_member1
Active Participant
0 Kudos

IResource Factory should be from the API

com.sapportals.wcm.repository.IResourceFactory;

Please check.

Thanks,

Anish

sureshmandalapu6
Active Contributor
0 Kudos

Yes, You are correct,

I imported that API and it is there already.

but ! in the code

IResourceFactory resourseFactory = ResourceFactory.getInstance();

I am getting error at ResourseFactory.getInstance() method.

Thanks

Suresh.

former_member1
Active Participant
0 Kudos

If u press ctrl space after ResourceFactory. do u get the corresponding method or not? i.e Are you able to view this method on the editor.

If yes please try ctrl and Click on the method name tocheck if it is goin to the right method.

sureshmandalapu6
Active Contributor
0 Kudos

Hi,

That issue solved. I got it. Now when I deploy my application I am getting the following error.

java.lang.NoClassDefFoundError: com/sapportals/portal/security/usermanagement/UserManagementException

Shows that there are no classes available. Any clue for this ?

thanks

Suresh

Former Member
0 Kudos

Hi frnds ,

Is there any way to access KM custom property through Webdynpro coding .??

Thanks in advance

Former Member
0 Kudos

You probably are missing a dependency for your WD project. The class should be in there:

SC: ENGFACADEDC: tc/je/usermanagement/api

Add a dependency to this DC to your WD-DC.

If it doesn't work, try a dependency to tc/bl/exception/lib (same SC), it solved the problem for me with another Exception class.