You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/02/13 01:15:59 UTC

DO NOT REPLY [Bug 17031] New: - Validation of required html:file elments passes when no file selected in form

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17031>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17031

Validation of required html:file elments passes when no file selected in form

           Summary: Validation of required html:file elments passes when no
                    file selected in form
           Product: Struts
           Version: 1.1 Beta 3
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator Framework
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: msqr@earthlink.net


When using <html:file> form elmenents, the JavaScript validation of these
elements passes the "required" test when I have not selected any file to upload.
Then in the servlet validation of the ValidatorForm object the file elements
pass validation again. I'm not sure if this is desired behavior or not, but for
me it was not. To get around (in the servlet validation anyway) my form bean's
validate method has code that checks the upload file's size, like tihs:

public class MyFormBean extends ValidatorForm {
  private FormFile file;
  ...
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errs = super.validate(mapping, request);
    if ( file == null || file.getFileSize() < 1 ) {
      errs.add(ActionErrors.GLOBAL_ERROR

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org