on 05-24-2007 12:15 PM
Hi
I am working on a file download application..I am using this code
try {
String resourcePath = WDURLGenerator.getResourcePathwdComponentAPI.getDeployableObjectPart(),ResultView.FILE_NAME);
wdContext.currentContextElement().setCtx_FileResource(this.getByteArrayFromResourcePath(resourcePath));
binaryType.setFileName(ResultView.FILE_NAME);
binaryType.setMimeType(WDWebResourceType.JPG_IMAGE);
}
catch (WDAliasResolvingException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(),
true);
} catch (Exception e) {
throw new WDRuntimeException(e);
}
My view name is "ResultView" and context name is ctx_FileResource.
I have to download a file from the server..
I have to download a properties file from the server..
I am getting error in this line.
<b>wdContext.currentContextElement().setCtx_FileResource(this.getByteArrayFromResourcePath(resourcePath));</b>
The error is Method getByteArrayFromResourcePath is not defined for the view..
Can anybody help on this.
Thanks
Shilpa
Hi,
Write the getByteArrayFromResourcePath() method in
//@@begin others
private byte[] getByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
byte[] part = new byte[10 * 1024];
while ((len = in.read(part)) != -1) {
out.write(part, 0, len);
}
in.close();
return out.toByteArray();
}
// store image file name in constant FILE_NAME
IWDModifiableBinaryType binaryType ;
//@@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 |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.