Hi Eveyone,
I have created a FileUploadItem & With some attributes.
I have set all them using dynamicform.setItems(..)
I have also added ValuesManager 'vm' to DynamicForm.
Servlet is getting called & I am retrieving parametes using
I am getting "isMultiPartRequest" as true in S.O.P.
But i am not getting formItems, S.O.P. shows zero as items length.
I have created a FileUploadItem & With some attributes.
I have set all them using dynamicform.setItems(..)
I have also added ValuesManager 'vm' to DynamicForm.
Code:
form.setCanSubmit(true); form.setAction(GWT.getModuleBaseURL() + "uploadFile"); form.setMethod(FormMethod.POST); form.setEncoding(Encoding.MULTIPART); form.setValuesManager(vm);
Code:
public String processFile(HttpServletRequest request, HttpServletResponse response){ boolean isMultiPartRequest = ServletFileUpload.isMultipartContent(createRequestContext(request)); String filePath = "c:\\temp"; System.out.println("processFile-isMultiPartRequest: " + isMultiPartRequest); if (isMultiPartRequest) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List items = upload.parseRequest(request); System.out.println("Length: " + items.size()); Iterator iterator = items.iterator(); while (iterator.hasNext()) { FileItem item = (FileItem) iterator.next(); if (!item.isFormField()) { String fileName = item.getName(); //String root = getServletContext().getRealPath("/"); File path = new File(filePath + "/uploads"); if (!path.exists()) { boolean status = path.mkdirs(); } File uploadedFile = new File(path + "/" + fileName); System.out.println(uploadedFile.getAbsolutePath()); item.write(uploadedFile); } else { System.out.println("Other: " + item.getName()); } } } catch (FileUploadException e) { e.printStackTrace(); return "-1"; } catch (Exception e) { e.printStackTrace(); return "-1"; } } return "7"; }
But i am not getting formItems, S.O.P. shows zero as items length.