on 04-04-2005 4:45 PM
Hi, i have an excel document in the server, and i want to know how to implement an action for download this file to the client machine.
if somebody can answer with an example code, much better.
thx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I hope this code will help you in using file download element.
Create a file download element,it has a property called data bind it to a context variable say "data" of type binary.
Now we have to take the data from the server read it into a byte array and set that to the context variable "data".
//Reading file from server into a byte array "b"
try
{
File output = new File("C:
test.doc"); //"C:
test.doc" is the file in server
int length=(int)output.length();
byte b[] = new byte[length];
FileInputStream in = new FileInputStream(output);
in.read(b);
in.close();
//Setting the data from file to the context variable data
wdContext.currentContextElement().setData(b);
}
catch(Exception ex)
{
wdComponentAPI.getMessageManager().reportSuccess("Error in File IO"+ex.toString());
}
//Create the attribute info of the context variable data
IWDAttributeInfo attinfo = wdContext.getNodeInfo().getAttribute("data");
//using attribute info create a Modifiable binary type
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attinfo.getModifiableSimpleType();
//Set the default file name
binaryType.setFileName("test.doc");
//Explicitly specify the file type , not mandatory
binaryType.setMimeType(WDWebResourceType.DOC);
Do get back for further clarifications.
Hope this helps you.
Regards,
Vijith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vijith thx a lot, i've tried just like the code that u give abobe, but it doesn't work, when i try to prove it launches a new ie with an exception like:
500 Internal Server Error
Application error occurs during processing the request.
Details: java.lang.NullPointerException
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.getClientWindow(ClientManager.java:837)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doExchangeProcessing(DispatcherServlet.java:139)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:95)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...
I don't know what is happening, i hope u can help me...
regards.
Hi Silva,
for more details about File download UI and corresponding APIs
follow this link
http://help.sap.com/saphelp_nw04/helpdata/en/c8/32cc6922fb6040a768652aaa0b6879/content.htm
Hope this helped you
Reagrds,
RK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx Anilkumar.
As i see in the thread that you suggest me, there are no way to implement a download action easily, or there are?.
Thx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Create a FileDownload UI element and bind it to a value attribute of type binary.
In the implementation write code to read content in the file to a byte array and set it to the binary Value attribute.
Check this link which has a code snippet.
http://help.sap.com/saphelp_nw04/helpdata/en/d9/376fcad4ba354db3093f147bc3ecd2/frameset.htm
Hope this might be helpful.
Regards,
Sowjanya.
Message was edited by: Sowjanya Chintala
Message was edited by: Sowjanya Chintala
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
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.