[
https://issues.apache.org/struts/browse/WW-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47165#action_47165
]
Bartłomiej Mocior commented on WW-3206:
---------------------------------------
The problem is looks different than described above. The javascript
serialization isn't working on <input type="file" ... /> fields. Files can't be
serialized to JSON, on the server side you will get error from
(FileUploadInterceptor I think) because you post FORM without enctype
multipart/form-data with empty file field.
First workaround that pops into my mind is to manually exclude file field from
JSON after serialization, and, if there is validation for file in the action
class, remove it.
The second, very similar to the first one is to exclude field AND give the
special parameter that will tell action to skip file validation, and in
validation method check that parameter and if it's true, skip file validation.
I was wondering if there is possibility to make full use of JSON validation,
even if we have FILE on form, maybe instead using form serialization, we can
post the form to the IFRAME with additional parameter and get the validation
result back from the IFRAME. This could be transparent (no code change would be
required), but still... the file would be transferred 2 times.
> instructions for jsonValidationWorkflowStack don't suggest how to avoid
> uploading files during the validation step
> ------------------------------------------------------------------------------------------------------------------
>
> Key: WW-3206
> URL: https://issues.apache.org/struts/browse/WW-3206
> Project: Struts 2
> Issue Type: Improvement
> Components: Other, XML Validators
> Reporter: Dale Newfield
> Assignee: Wes Wannemacher
> Fix For: 2.1.9
>
>
> http://struts.apache.org/2.x/docs/ajax-validation.html shows how to submit
> the form via ajax in such a way that it will not invoke the action, but only
> return the validation errors as json. If the form includes a file to be
> uploaded, though, it will be uploaded both in this validation submission step
> and then in the actual form submission step. Modification of the
> documentation/example code to show how to avoid that would be useful.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.