on 06-17-2009 5:50 AM
Hi All,
There is a new requirement.There will be one browse button.Using this browse button user will search the document from the local machine and select the required document.Then there is 2nd button with name Upload.When user will click on this button the attached document will save in a External URL (IDM-User for document repository ).
Can anybody tell me how to implement this?
I have searched the forum ,there i found only option that is uploading the document to KM.KM is part of EP porta.So we can upload the document easily by implementing the blogs present in SDN.
However i didn't get any help file related to how to upload the document to exterval URL.
Thanks
Susmita
Hi Susmita,
Hope the following procedure will help you with your requirement.
1. Place a FileUpload UI Element in the view of webdynpro application
2. Create a context value attribute of type 'Resource' (you can find this type under 'com.sap.ide.webdynpro.uielementdefinitions )
3. Bind the 'data' property and 'resource' property of the FileUpload UI element.
4. Place a button near the file upload and create an action for this button
5. Place this code in the action of the button
try{
BufferedInputStream bInput=new BufferedInputStream(wdContext.currentContextElement().get<AtrritbuteName>().read(true)); // Attribute Name is the name of 'Resource' type attribute bound to FileUpload element
URL targetUrl=new URL("<specify the url here>"); //URL is from java.net package
URLConnection urlConnection=targetUrl.openConnection();
BufferedOutputStream bOutput=new BufferedOutputStream(urlConnection.getOutputStream());
final int BUFFER=2048;
int count=0;
byte[] data=new byte[BUFFER];
while((count=bInput.read(data,0,BUFFER))!=-1){
bOutput.write(data,0,count);
}//end while
}//end try
catch (FileNotFoundException e) {
// handle exception
} catch (MalformedURLException e) {
// handle exception
} catch (IOException e) {
// handle exception
}
remember to close all streams in a 'finally' block.
If it is a location in the disk of server that you want to upload the file, instead of using URL and URLConnection you can use the BufferedOutputStream as
BufferedOutputStream bOutput=new BufferedOutputStream(new FileOutputStream("<path of file>"));
Regards,
Shabeer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sabeer,
When i am trying to define the data type of context value attribute as Resource.I am not getting the option 'com.sap.ide.webdynpro.uielementdefinitions in my local NWDS.Also i am getting Data property of FileUploadUI element.There is no property with name Resource for the UI element.
Please let me now how i will proceed and what should be the type of context attribute which is bound to FileUploadUI element .
Thanks Susmita
Hi Sushmita,
its simple only ,we have done this thiong already you need to have destination's url and specify on click upload function.Just store teh fiel into temp variable and in that temp url of external location should be there.it will be saved.
Regards,
Anu
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.