/*******************************************************************************
 * Copyright 2019 2Fi Business Solutions Ltd.
 *
 * This code is part of the Core project.
 *
 * This code is copyrighted. Under no circumstances should any party, people,
 * or organization should redistribute any portions of this code in any form,
 * either verbatim or through electronic media, to any third parties, unless
 * under explicit written permission by 2Fi Business Solutions Ltd.
 ******************************************************************************/
package com.ffii.core.web;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import com.ffii.core.support.SimpleDateEditor;
import com.ffii.core.support.SimpleIntegerEditor;
import com.ffii.core.support.SimpleStringTrimToNullEditor;

/**
 * ControllerAdvice is used to define @ExceptionHandler, @InitBinder, and @ModelAttribute methods that apply to all @RequestMapping methods.
 *
 * @author Patrick
 */
@org.springframework.web.bind.annotation.ControllerAdvice
public class ControllerAdvice {

	@InitBinder
	public void initBinder(WebDataBinder binder) {
		binder.registerCustomEditor(String.class, new SimpleStringTrimToNullEditor());
		binder.registerCustomEditor(Integer.class, new SimpleIntegerEditor());
		binder.registerCustomEditor(java.util.Date.class, new SimpleDateEditor());
	}

}
