You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/05/22 22:47:26 UTC
svn commit: r540745 -
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java
Author: bommel
Date: Tue May 22 13:47:25 2007
New Revision: 540745
URL: http://svn.apache.org/viewvc?view=rev&rev=540745
Log:
(TOBAGO-407) tc:validateFileItem forces required="true"
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java?view=diff&rev=540745&r1=540744&r2=540745
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/validator/FileItemValidator.java Tue May 22 13:47:25 2007
@@ -31,8 +31,6 @@
import javax.faces.application.FacesMessage;
/*
- * Created by IntelliJ IDEA.
- * User: bommel
* Date: Oct 30, 2006
* Time: 9:59:13 PM
*/
@@ -52,7 +50,6 @@
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
if (value != null && component instanceof UIFileInput) {
FileItem file = (FileItem) value;
-
if (maxSize != null && file.getSize() > maxSize) {
// TODO better error text i18n
Object[] args = {maxSize, component.getId()};
@@ -60,7 +57,8 @@
DoubleRangeValidator.MAXIMUM_MESSAGE_ID, FacesMessage.SEVERITY_ERROR, args);
throw new ValidatorException(facesMessage);
}
- if (contentType != null
+ // Check only a valid file
+ if (file.getSize() > 0 && contentType != null
&& !ContentType.valueOf(contentType).match(ContentType.valueOf(file.getContentType()))) {
// TODO i18n
String text = "ContentType " + file.getContentType() + " not expected.";