1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.web.bind;
  17. import javax.servlet.ServletException;
  18. import javax.servlet.ServletRequest;
  19. /**
  20. * Callback that allows for initialization of a binder with
  21. * custom editors before the binding. Used by BindUtils.
  22. * @author Jean-Pierre PAWLAK
  23. * @since 08.05.2003
  24. * @see BindUtils#bind(ServletRequest,Object,String,BindInitializer)
  25. * @see BindUtils#bindAndValidate(ServletRequest,Object,String,org.springframework.validation.Validator,BindInitializer)
  26. */
  27. public interface BindInitializer {
  28. /**
  29. * Initialize the given binder instance, e.g. with custom editors.
  30. * Called by BindUtils#bind. This method allows you to register custom
  31. * editors for certain fields of your command class. For instance, you will
  32. * be able to transform Date objects into a String pattern and back, in order
  33. * to allow your JavaBeans to have Date properties and still be able to
  34. * set and display them in for instance an HTML interface.
  35. * @param request current request
  36. * @param binder new binder instance
  37. * @throws ServletException in case of invalid state or arguments
  38. * @see org.springframework.validation.DataBinder#registerCustomEditor
  39. * @see BindUtils#bind(ServletRequest,Object,String,BindInitializer)
  40. */
  41. public void initBinder(ServletRequest request, ServletRequestDataBinder binder)
  42. throws ServletException ;
  43. }