Java Code Examples for org.springframework.web.multipart.support.StringMultipartFileEditor

The following examples show how to use org.springframework.web.multipart.support.StringMultipartFileEditor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example 2
Source Project: spring-analysis-note   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example 3
Source Project: spring-analysis-note   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example 4
Source Project: java-technology-stack   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example 5
Source Project: java-technology-stack   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example 6
Source Project: java-technology-stack   Source File: WebRequestDataBinderTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example 7
@Test
public void testMultipartFileAsString() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals("Juergen", target.getName());
}
 
Example 8
@Test
public void testMultipartFileAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(1, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
}
 
Example 9
@Test
public void testMultipartFilesAsStringArray() {
	TestBean target = new TestBean();
	WebRequestDataBinder binder = new WebRequestDataBinder(target);
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());

	MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
	request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
	request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
	binder.bind(new ServletWebRequest(request));
	assertEquals(2, target.getStringArray().length);
	assertEquals("Juergen", target.getStringArray()[0]);
	assertEquals("Eva", target.getStringArray()[1]);
}
 
Example 10
Source Project: AlgoTrader   Source File: GrailsDataBinder.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility method for creating a GrailsDataBinder instance
 *
 * @param target The target object to bind to
 * @param objectName The name of the object
 * @return A GrailsDataBinder instance
 */
public static GrailsDataBinder createBinder(Object target, String objectName) {
	GrailsDataBinder binder = new GrailsDataBinder(target, objectName);
	binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
	binder.registerCustomEditor(Currency.class, new CurrencyEditor());
	binder.registerCustomEditor(Locale.class, new LocaleEditor());
	binder.registerCustomEditor(TimeZone.class, new TimeZoneEditor());
	binder.registerCustomEditor(URI.class, new UriEditor());

	registerCustomEditors(binder);

	return binder;
}
 
Example 11
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example 12
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example 13
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}
 
Example 14
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
}