on 11-17-2015 4:33 PM
Hi Everybody,
I want to display JPG images in my Web Dynpro Java Application. The images are stored in a PC, but I dont want to open the file explorer and select the file using FileUpload UI. I need to write in my code a path like this: D:\100301.jpg and display the image.
I have used this code and it doesn't work, but if I choose the file with the FileUpload UI, the image is displayed succesfully.
String file = "D:\\100301.jpg";
IWDResource resource = null;
try {
resource = WDResourceFactory.createResource(file.getBytes(),"100301",WDWebResourceType.JPG_IMAGE);
wdContext.currentResourceElement().setImgResource(resource);
wdContext.currentResourceElement().setImgURL(
wdContext.currentResourceElement().getImgResource().getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
} catch (Exception e) {
e.printStackTrace();
}
The attribute ImgURL is bound to the image source property.
So, can someone help me with any suggestion in order to solve this issue?
Thanks!!!
IWDResource resource = WDResourceFactory.createCachedResource(new ByteArrayInputStream(wdContext.currentFile_OutputElement().getChaE_String()),"JPG",WDWebResourceType.JPG_IMAGE,true);
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.toString(),"Image Window");
window.show();
Please try the above code. wdContext.currentFile_OutputElement().getX_String() is the XString attribute from the BAPI and the image is of type JPEG. if you want to open only JPEG then use this or use the resourcetype as Unknown.
Or
click on the "Navigator" and find the respective project and navigate to the " comp\src\mimes\Components\<ur component name>" you can see all the images
weContext.currentcontextelment.setImage("Lotus.jpg");
Or
You can do it dynamically in wdDoModifyView()
IWDImage img=(IWDImage)view.getElement("<Image UI element ID>");
img.setHeight("200");
img.setWidth("400");
Kindly let me know if you need any more information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay,
Thanks for your answer. But it is not working. The thing is that the images are stored in my pc, i tried to use an RFC for getting the xstring image and it works when it is executed from SAP but when i call the RFC from the portal (webdynpro), the RFC shows a Dump and cannot access the file. (Exception condition "NO_BATCH" raised., error key: RFC_ERROR_SYSTEM_FAILURE)
Do you know how can i get the xstring or byte array without bapi or RFC? only using webdynpro JAVA? and then use the code you told me before?
Thanks!!
Please check this code. it should be useful Example-1 and Example-2
File file = new File("text.jpg");
FileInputStream fis = new FileInputStream(file);
byte[] buf = new byte[1024];
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
// Here populate the RFC table
}
} catch (IOException ex) {
}
Kindly let me know if you need any more information.
no way.
you are in dead end.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.