on 10-11-2007 11:36 AM
Hi all,
I have an image in the server, say "c:\hai.jpg", through my application i want to open this image in a new external window on click of a button.
I used the following code,
String file ="C:\images\p.JPG";
final byte[] content = this.getByteArrayFromResourcePath(file);
final IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.JPG_IMAGE);
resource.setResourceName("p."+resource.getResourceType().getFileExtension());
try
{
final IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getAbsoluteURL(), "WD_Filedownload", true);
window.open();
}
catch(Exception e){
wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
}
This code opens a new Internet Explorer, but not the image. When i printed the AbsoluteURL of the resource, its printing null. Where am i going wrong?
Thanks in advance,
Pravin
Have you checked the content of the byte array before creating the resource? Does it contain the image data?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Armin,
I am using this byte array code
private byte[] getByteArrayFromResourcePath(String resourcePath)throws FileNotFoundException, IOException
{
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int length;
byte[] part = new byte[10 * 1024];
while ((length = in.read(part)) != -1) {
out.write(part, 0, length);
}
in.close();
return out.toByteArray();
}
Thanks
Pravin
Pravin,
Try placing the image in src->mimes->Components->com.xxx.xxx.mycomponent folder.
Lemme know if that helps.
Regards,
Rajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.