on 03-23-2009 6:17 AM
Hello all,
Hope you are having a nice time.
I have a requirement to upload a file and then download it.
I have a used a FileUpload UI element which has a predefined UI format. ie an input field and a button.
My Questions are:
1) If i want a link only on my UI page --> Upload. This should open a dialog window of the file selection. (same as FileUpload UI element). Is this possible. Can i link my link element to FileUpload UI without displaying FileUpload UI element onto the webdynpro screen?
2) Suppose i have selected a file from File select dialog using the File Upload element. Now is it that the file is attached to this context element and i can access it later for downloading it?
3) If anser to above question is yes, how do i download the file?
Thnks
Hi
1. Link UI is just link a Action So u can't open dialog window for file selection by this,But yes u can open a popup with help of this action further u have to use file Upload UI element for file selection. Yes u can achieve this function without using this , in this case u have to give the file parh at runtime (thats why File Upload UI element is there)
2.No, U have to manually take the content of the file into contest node , further data will there for other operations
3. Take help from this thread which has all your [needs|;
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yogesh,
This can take care of .doc file as well. However you have to write a different code in the Parse method for the .doc file. Please refer to these links for reading the doc file. You can add this to the parse method:
http://www.hiteshagrawal.com/java/reading-word-document-in-java
Please check this link as well where I have clearly described the way to perform the FileUpload operation.
I hope this helps you and solve your issue!
Thanks and Regards
Pravesh
Edited by: Pravesh Verma on Mar 23, 2009 2:58 AM
Hi Pravesh,
From the message you have put in last, it says about the File path.
So if my understanding goes correct, since i wll have the path of the file, i can use that same path later to download the same file. Am i correct?
For this path, i can have a string type attribute which holds that value. Correct?
Thnks
Hi Yogesh,
Yes you are correct. However it will not be a String value. it wil be a resource value from you can extract the file path very easily using the API provided.
I hope this helps! Also please refer to the link which I have posted above. It shows you the way to read a .doc file. You may have to add some external jars for the same. Just check in the link.
If you have any furtehr issues please revert back.
Thanks and Regards,
Pravesh
Hi Yogesh,
Its nothing but a simple FileOutputStream object. You can set the value to this stream. In my case I was using the FileOutputStream to save the resource at my server C:/ directory, therefore I have just documented it that ways!
In terms of local development server will be that place where your applicationis running. That means where the WS is installed. I was having the server at my local machine, however you may have a distributed environment where the WAS is installed to some other system instead of local system.
I hope this is clear! Kindly revert back if you need any further information.
Thanks and Regards,
Pravesh
Hi Pravesh,
So if i understand this correctly,
For local machine, let me say i have selected a folder for uploading my file.
This means that that path will be hardcoded.
For eg C:\Webdynpro\
This means if i am picking up a file from my own system and just copying it to a specific location just to simulate the whole concept.
And then for downloading i again give the same path (hard-coded) and locate the file with file name.
Am i correct?
Hi Yogesh,
Please note that while uploading a file, you just select the resource from your local machine. Thats is all.. After that during the upload process the file will be uploaded to the server location. Not at your local system (condition apply: If your server is at your local machine then it will upload at your local machine only).
While downloading it will again take the resource path from the server you need not have to hardcode it. You have to use the API's from getting the file location and path.
Please check this help.sap.com link:
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/fdf9c528d45171e10000000a1553f7/frameset.htm
I hope this helps!
Thanks and Regards
Pravesh
Hi Yogesh,
No no.. Nothing like FTP etc.. Dear you already have a server. Its the same server where you are deploying your application.
The uploaded file will also go to the same server to a specified folder.
Please understand that all the web applcaition including your webdynpo application runs on WAS which is Web Application Server (This is the same server where you are deploying and running your webdynpro applications).
I hope it is clear now!
Thanks and Regards
Pravesh
Hi Yogesh,
Answer to your first question is No. You cannot trigger the upload event on the click of the link to action event. This is not possible.
Regarding the second requirement. This is somewhat achievable. Since you have binded the Upload UI element with some context attribute therefore that valueo f the path exist in the attribute. You can access that path and then write the code of upload by accessing the path from that attribute.
Check these links for file upload:
/people/bertram.ganz/blog/2007/05/25/new-web-dynpro-java-tutorials--uploading-and-downloading-files-in-sap-netweaver-70
Also please check the way in which you have to create the resource attrib ute which needs to be binded:
1) In your view, create a UI element File Upload
2) Create a context attribute say Source of type(com.sap.ide.webdynpro.uielementdefinitions.Resource)
i) Type -
ii) Choose Simple type -
iii) In that package choose Resource and then Click ok
3) Switch to Layout tab, bind the resource property with this context attribute(source)
I hope this helps!
Thanks and Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pravesh,
Thanks a ton for your quick reply. I really appreciate it.
However, i still have some doubts.
1) Over the Link possibility. Let us say, i have a Link UI element and a FileUploadUI element on my screen. FileUpload is not visible on screen. Now on my link action i link upto the FileUpload UI and call up the action (which may be standard of course) which actually calls up the upload file selection window. (I hope i am not sounding too foolish )
2) With regards to the second point, you have mentioned that i will have the path. Is this path the local system file system path?
I am new to dynpro and my understanding is that the FileResource Context attribute which i have createed will hold the file instance itself. So with help of it i can transfer file to an other context attribute (of the same type ofcourse)
Please help!!!!!!!
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.