on 04-10-2008 5:23 AM
Hello,
I have requirement to download a file from server using IWDFileDownload and its working for first time. after changing the contents of the file and when i try to download the same file it show the old contents in the file and in actual file those records don't exists.
(i tried to download the excel file)
Any suggestions
Thanks in advance
- Vinod V
Hi Vinod,
Create a binary type context.
e.g here is ctx_va_downloadlog is of binary type and assigned it to file download UI element
IWDAttributeInfo attributeInfo =wdContext.getNodeInfo().getAttribute(
IPrivateFileDownloadView.IContextElement.CTX__VA__DOWNLOADLOG);
IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
binaryType.setMimeType(WDWebResourceType.TXT);
+mention the location of file on server+
+String filePath= server file path+
start to read file..
StringBuffer contents = new StringBuffer();
try {
BufferedReader input = new BufferedReader( new FileReader(filePath));
String line = null;
while (( line = input.readLine()) != null){
contents.append(line);
contents.append(System.getProperty("line.separator"));
}
}
catch (FileNotFoundException ex) {
}
catch (IOException ex){
}
try
{
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
outStream.write(contents.toString().getBytes());
wdContext.currentContextElement().setCtx_va_downloadlog(outStream.toByteArray());
}
catch(Exception e){
}
This method need to be execute every time when you try to download file from server. to fetch updated file from server.
well using the append property and seperator you will be able to download you file properlly. adjust them according to whether file is in .txt,.log,.xls,.xml format
Edited by: snehal kendre on Apr 10, 2008 7:19 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi snehal
I have followed documents from SDN and if i am following your code; what would be the inputs that i have to specify to the FileDownload UI element properties such as Data (type IWDInputStream) and Resource(Resource)? And where i have to specify the code in implementation as one of the document descrided to mention the code in calculatedAttributeGetter (belongs to the property of object of type IWDInputStream).
Regards
Vinod V
HI Vinod,
in filedownload UI element for data mention the context. e.g. ctx_va_downlaod.
the code i sent you is somwhat like file reader.
create one method for code. which reads the file and store it into your context. then when you click on file download UI element data in context is converted into file.
you can do like this.
1. Give a button as download.
2. On click of button give a popup containing filedownload UI element.
3. in init method of popup put this code.
4. on close of popup destroy that context. as it consumes memory.
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.