-
1. Re: How to test rich:fileUpload with jsfunit
ssilvert Apr 10, 2008 9:39 AM (in response to jadtn)I haven't looked at the new components that shipped with RichFaces 3.2. As far as I know, nobody has tried fileUpload yet. Hopefully, it's something I can get to soon. If you figure it out please let us know.
Stan -
2. Re: How to test rich:fileUpload with jsfunit
laurentn Apr 10, 2008 10:08 AM (in response to jadtn)Here is an example of what I tested:
public void setFileParameter(String id, String filename)
throws SAXException
{
if (filename == null) {
return;
}
File f = new File(filename);
if (!f.exists()) {
System.out.println("Page.setFileParameter: file does not exist: " + f.toString());
return;
}
WebForm forms[] = client.getWebResponse().getForms();
WebForm webForm = null;
for (int i = 0; i < forms.length; i++) {
if (client.getClientIDs().isAncestor(id, forms.getID())) {
webForm = forms;
}
}
if (webForm == null) {
throw new ComponentIDNotFoundException("form not found");
}
UploadFileSpec[] uploadFileSpec = new UploadFileSpec[1];
InputStream stream = null;
try {
stream = new FileInputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
uploadFileSpec[0] =
new UploadFileSpec(filename, stream, getContentType(filename));
webForm.setParameter(id, uploadFileSpec);
Element element = DOMUtil.findElementWithID(id, client.getUpdatedDOM());
element.setAttribute("value", filename);
}
Laurent -
3. Re: How to test rich:fileUpload with jsfunit
jadtn Apr 12, 2008 2:18 AM (in response to jadtn)Thanks Laurent. It was not simple..I m going to try your solution