on 03-12-2009 7:53 AM
Hi y'all,
im using upload UI element to upload files to KM on a Web Dynpro Java application. Works fine as long as u use the browse button and function.
But the input field is editable! If you type in something sensless my upload functions runs into a infinite loop.
As far as I discovered I can only set the whole upload element to disabled not just the input field.
I tried to determine if the InputStream has a proper size but it seams that the loop is on reading stream already.
Anyone discovered same problem before? I'm sure there is one thread on SDN where somebody had same question but didn't get a proper answer.
Thanks a lot for help!
Christian
try{
String path = wdContext.currentContextElement().getCurrentFolder() + wdContext.currentContextElement().getKMFolder();
ResourceContext context = new ResourceContext(getEP5User());
RID rid = RID.getRID(path);
IResourceFactory factory = ResourceFactory.getInstance();
ICollection folder = (ICollection) factory.getResource(rid,context);
String fileName = wdContext.currentFileElement().getFileresource().getResourceName();
InputStream inputStream = wdContext.currentFileElement().getFileresource().read(false);
File destfile = new File(fileName);
FileOutputStream out = new FileOutputStream(destfile);
byte[] readData = new byte[1024];
int i = inputStream.read(readData);
while ( i != -1 ){
out.write(readData, 0, i);
i = inputStream.read(readData);
}
out.close();
BufferedInputStream bufInStream = new BufferedInputStream(new FileInputStream(destfile));
Content con = new Content( bufInStream , "application/octet-stream", -1,"UTF-16");
IResource newResource = folder.createResource(fileName, null, con);
}catch (Exception e){
msgMngr.reportException("Die Datei konnte nicht erfolgreich hochgeladen werden!",true);
}
Well, I am not sure the below code would resolve the issue. Once I have got similar issue (Infinite loop at file UpLoad) with Firefox too.
if( destfile.exists()) {
FileOutputStream out = new FileOutputStream(destfile);
byte[] readData = new byte[1024];
int i = inputStream.read(readData);
while ( i != -1 ){
out.write(readData, 0, i);
i = inputStream.read(readData);
}
out.close();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your answer, but im sorry didn't solve the problem!
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is a known issue in IE, It occurs when we try to enter values directly to the inputfield which is part of the fileupload.
Microsoft have some work arounds to get rid of this, but not possible in Webdynpro.
http://help.sap.com/saphelp_nw04s/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm
Regards
Ayyapparaj
URL Added
Edited by: Ayyapparaj KV on Mar 12, 2009 8:50 PM
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.