@SuppressWarnings("unchecked") @Test public void process_submission_calls_validator() throws Exception { MultipartDecoder decoder = mockMultipartDecoder(); UploadedFile uploadedFile = mockUploadedFile(); FieldValidator<Object> validate = mockFieldValidator(); ComponentResources resources = mockComponentResources(); FieldValidationSupport support = mockFieldValidationSupport(); Upload component = new Upload(null, validate, decoder, null, resources, support); expect(decoder.getFileUpload("test")).andReturn(uploadedFile); expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce(); support.validate(uploadedFile, resources, validate); replay(); component.processSubmission("test"); verify(); }
@SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { UploadedFile uploaded = decoder.getFileUpload(controlName); if (uploaded != null && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) { uploaded = null; } try { fieldValidationSupport.validate(uploaded, resources, validate); } catch (ValidationException ex) { validationTracker.recordError(this, ex.getMessage()); } value = uploaded; }
Upload extends AbstractField { @SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { UploadedFile uploaded = decoder.getFileUpload(controlName); if (uploaded != null && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) { uploaded = null; } try { fieldValidationSupport.validate(uploaded, resources, validate); } catch (ValidationException ex) { validationTracker.recordError(this, ex.getMessage()); } value = uploaded; } }
Upload extends AbstractField { @SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { UploadedFile uploaded = decoder.getFileUpload(controlName); if (uploaded != null && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) { uploaded = null; } try { fieldValidationSupport.validate(uploaded, resources, validate); } catch (ValidationException ex) { validationTracker.recordError(this, ex.getMessage()); } value = uploaded; } Upload();   Upload(UploadedFile value, FieldValidator<Object> validate, MultipartDecoder decoder, ValidationTracker tracker,
           ComponentResources resources, FieldValidationSupport fieldValidationSupport); }
Upload extends AbstractField { @SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { UploadedFile uploaded = decoder.getFileUpload(controlName); if (uploaded != null && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) { uploaded = null; } try { fieldValidationSupport.validate(uploaded, resources, validate); } catch (ValidationException ex) { validationTracker.recordError(this, ex.getMessage()); } value = uploaded; } Upload();   Upload(UploadedFile value, FieldValidator<Object> validate, MultipartDecoder decoder, ValidationTracker tracker,
           ComponentResources resources, FieldValidationSupport fieldValidationSupport); @Override boolean isRequired(); void afterRender(MarkupWriter writer); UploadedFile getValue(); }
Upload extends AbstractField { @SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { UploadedFile uploaded = decoder.getFileUpload(controlName); if (uploaded != null && (uploaded.getFileName() == null || uploaded.getFileName().length() == 0)) { uploaded = null; } try { fieldValidationSupport.validate(uploaded, resources, validate); } catch (ValidationException ex) { validationTracker.recordError(this, ex.getMessage()); } value = uploaded; } Upload();   Upload(UploadedFile value, FieldValidator<Object> validate, MultipartDecoder decoder, ValidationTracker tracker,
           ComponentResources resources, FieldValidationSupport fieldValidationSupport); @Override boolean isRequired(); void afterRender(MarkupWriter writer); UploadedFile getValue(); static final String MULTIPART_ENCTYPE; }