org.springframework.web.multipart.support.ByteArrayMultipartFileEditor Java Examples

The following examples show how to use org.springframework.web.multipart.support.ByteArrayMultipartFileEditor. 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 File: BaseController.java    From ankush with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Set up a custom property editor for converting form inputs to real
 * objects.
 *
 * @param request the current request
 * @param binder the data binder
 */
@InitBinder
protected void initBinder(HttpServletRequest request,
		ServletRequestDataBinder binder) {
	binder.registerCustomEditor(Integer.class, null,
			new CustomNumberEditor(Integer.class, null, true));
	binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(
			Long.class, null, true));
	binder.registerCustomEditor(byte[].class,
			new ByteArrayMultipartFileEditor());
	SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy.MM.dd G 'at' HH:mm:ss z");
	dateFormat.setLenient(false);
	binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
			dateFormat, true));
}
 
Example #2
Source File: GrailsDataBinder.java    From AlgoTrader with 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 #3
Source File: TargetSeedsHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      
      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
 
Example #4
Source File: TreeToolController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Boolean.class, "propagateDelete", new CustomBooleanEditor(true));
      
      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
 
Example #5
Source File: PetDescriptionUploadController.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Register the PropertyEditor for converting from a MultipartFile to an array of bytes.
 */
@InitBinder
public void registerMultipartEditor(WebDataBinder binder) {
	binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}