on 07-29-2008 7:17 AM
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
Hi,
Easiest option is use the link from the KM .
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<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
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
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.
Hi,
The below line of code shows that the REsourceFactory .getInstance() is not there in ResourseFactory.
IResourceFactory resourseFactory = ResourceFactory.getInstance();
Thanks
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You probably are missing a dependency for your WD project. The class should be in there:
SC: ENGFACADE | DC: 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.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.