First of all I tried to determine what was wrong in my static files in the backend as you said I must receive a multipart request if I put the right content into this files. But despite reading the docs I haven't been able to achieve it. The test always shows the same error: Uncaught TypeError: Cannot read property 'transactionNum' of undefined. I cannot understand which data must be put into the static files to achieve that the components works properly.
After that I decided to use the FileItem instead of the MultiFileItem just in case it was easier to use. But I have not been able to make this component launch a multipart request neither. In this component as the dinamic form contains the FileItem I used the Encoding.MULTIPLE instead of the Encoding.NORMAL.
After checking the SmartGWT SDK source code I have found in DynamicForm.js the property MULTIPART_ENCODING that is mapped to "multipart/form-data" and the property MULTIPART mapped to "multipart". And I remembered that I told you that the Javadoc in the DynamicForm.setEnconding method was speaking about a value (MULTIPART_ENCODING) that was not in the DSEncoding enum. I thought that was a problem in the Javadoc but now I think is a problem in the code related with this.
To do a small check isolating pieces, I have written an HTML with two forms. Each form contains only an input type file but one form has the enctype to multipart and the other to multipart/form-data. The results after submitting each form are:
- The form with the multipart enctype never launches a Multipart request.
- The form with the multipart/form-data launches a Multipart request.
The HTML used to test the behaviour of the different enctypes:
<!DOCTYPE html>
<html lang="en">
<body>
<form method="POST" action="fileUploadServlet" enctype="multipart">
<div>NOT working version (This version doesn't produces a multipart
request):</div>
<input type="file" name="file" id="file" />
<input type="submit" value="Upload" />
</form>
<br />
<form method="POST" action="fileUploadServlet"
enctype="multipart/form-data">
<div>Working version (This version produces a multipart request):</div>
<input type="file" name="file" id="file" /> <input
type="submit" value="Upload" />
</form>
</body>
</html>
<html lang="en">
<body>
<form method="POST" action="fileUploadServlet" enctype="multipart">
<div>NOT working version (This version doesn't produces a multipart
request):</div>
<input type="file" name="file" id="file" />
<input type="submit" value="Upload" />
</form>
<br />
<form method="POST" action="fileUploadServlet"
enctype="multipart/form-data">
<div>Working version (This version produces a multipart request):</div>
<input type="file" name="file" id="file" /> <input
type="submit" value="Upload" />
</form>
</body>
</html>
Leave a comment: