struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 36687] - Struts not populating form values when maxFileSize exceeded during file upload
Date Fri, 17 Feb 2006 03:58:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36687>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36687





------- Additional Comments From niallp@apache.org  2006-02-17 04:58 -------
(In reply to comment #3)

> If form population must terminate after the maximum file size is exceeded then
> does it make sense to add another controller attribute to specify a resource
> bundle property that gets added to action errors, treat maximum file size
> exceeded as a validation error, and terminate validation? Seems a bit awkward
> and harsh but for lack of a better solution...
> Any ideas?

As a workaround, you could do this yourself in the ActionForm's validate 
method, if you're using Commons Validator, then extend the appropriate 
ValidatorForm...

public ActionErrors validate(ActionMapping mapping,
        HttpServletRequest request) {

    Boolean maxLengthExceeded = (Boolean)request.getAttribute(
        MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);

    if ((maxLengthExceeded != null)
        && (maxLengthExceeded.booleanValue())) {
                    return;
        ActionErrors errors = new ActionErrors();
        errors.add(new ActionMessage(...));
        return errors;
    }

    return super.validate(mapping, request);

}

If you wanted you could even re-try the form population - although as Martin 
noted, depending on where the multipart processing stopped, not all fields may 
be available. The standard struts multipart implementation adds String 
parameters to the (wrapped) request, so you could do something like the 
following

  try {
      BeanUtils.populate(this, request.getParameterMap());
  catch(Exception e) {
      ....
  }

For Struts 1.3 one option would be to throw an exception - then people could 
configure an exception handler to deal with it.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message