-
1. Re: rich:fileUpload getFileName() and getMime() resolves to null
derkd Oct 17, 2011 5:51 AM (in response to derkd)I got it partly working. I also use PrettyFaces and that's where probably the problem is.
When I replace this:
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
with this:
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNCHRONOUS</dispatcher>
</filter-mapping>
Now I get the filename back but the getMime() still resolves to null...
-
2. Re: rich:fileUpload getFileName() and getMime() resolves to null
derkd Oct 17, 2011 7:23 AM (in response to derkd)Well I'm a bit further.
The mime type is set when the setName() of the UploadedImage is called. So you have to make sure that the setName has been called before calling the getMime(). Next there is a bug in the setName() of the UploadedImage in the showcase. I added a comment to fix this (https://issues.jboss.org/browse/RF-11218)
public void setName(String name) {
int extDot = name.lastIndexOf('.');
if (extDot > 0) {
String extension = name.substring(extDot + 1);
if ("bmp".equals(extension)) {
mime = "image/bmp";
} else if ("jpg".equals(extension)) {
mime = "image/jpeg";
} else if ("gif".equals(extension)) {
mime = "image/gif";
} else if ("png".equals(extension)) {
mime = "image/png";
} else {
mime = "image/unknown";
}
}
}
the attribuut name isn't set!
this must be added
this.name = name;
Regards,
Derk