Questions tagged [spring-mvc-initbinders]

66 questions
11
votes
2 answers

Customize mapping request parameters and fields inside the DTO ?

I have the following class: public class MyDTO { private String kiosk; ... } and following url: http://localhost:1234/mvc/controllerUrl?kiosk=false and following controller method: @RequestMapping(method = RequestMethod.GET,…
gstackoverflow
  • 31,683
  • 83
  • 267
  • 574
7
votes
0 answers

How to setup FORM binding in Spring MVC 4.3 to have in controller an appropriate child object of the inheritance tree

I'm making changes in a very old application. which is using Spring MVC 4. I need to post data from a form:form tag within in JSP for Spring controller. UI is fixed and I can only make changes at server side. Based upon a specific field in my…
7
votes
1 answer

Spring mvc miss id of dependent collection when combine form object from jsp

I have following controller to return view: @RequestMapping(value = "/admin/adminUsers", method = RequestMethod.GET) public String adminUsers(ModelMap model, HttpSession session) { Set users =…
gstackoverflow
  • 31,683
  • 83
  • 267
  • 574
7
votes
1 answer

org.springframework.validation.BeanPropertyBindingResult Exception

Hi I am a new to spring framework. I have done a small example where I tried to validate my input field using spring validation api. This is the code @RequestMapping(value = "/applicationFormSubmit", method = RequestMethod.POST) public String…
Chandan Sarma
  • 258
  • 1
  • 5
  • 18
6
votes
1 answer

AspectJ: Autowired fields are null in Initbinder

I just implemented AspectJ like described here: https://stackoverflow.com/a/10998044/2182503 This solution works fine, until I noticed that my @Autowired fields are null within @InitBinder. The fields are only null within the…
4
votes
2 answers

@Valid annotation is ignored when applied to MultipartFile object

This is my controller. It accepts a multipart/form-data request with two fields, form and file. The form field is a MyObject, the file field is a MultipartFile. Both variables are annotated with @Valid, and accordingly, I would expect Spring to…
4
votes
1 answer

Failed to convert value of type 'org.springframework.web.multipart.commons.CommonsMultipartFile' to required type

I have following controller method: @RequestMapping(value = "/owner/terminals/save", method = RequestMethod.POST) public String saveTerminal( @RequestParam(value = "name") String name, @RequestParam(value = "file")…
gstackoverflow
  • 31,683
  • 83
  • 267
  • 574
4
votes
1 answer

Renaming a nested property of a Spring MVC model attribute

I have the following form: public class ChildcareWorkerAdvertisementForm extends AbstractForm { @Valid @Override //Rename the property from "model" to "advertisement"? public…
balteo
  • 20,469
  • 52
  • 196
  • 362
3
votes
1 answer

Configure two @InitBinder to work with the same Model or Entity but for different @RequestMappings

I have a controller where works fine, It can register and update an entity, just how the following about to create the forms to save and update an entity respectively @RequestMapping(value="/registrar.htm", method=RequestMethod.GET) public String…
Manuel Jordan
  • 11,959
  • 15
  • 69
  • 111
3
votes
2 answers

How to specify custom validate error message in SimpleDateFormat using Spring MVC

In my Smpring MVC application I'm validating dates using SimpleDateFormat as a custom editor in WebDataBinder. When entered date does not match required pattern I get raw error message in my form:errors tag like: Failed to convert property value of…
3
votes
1 answer

How to define multiple initBinders

Would it be possible to have multiple initBinder Methods inside a single Controller? Where each InitBinder() (see code) depends on a unique request handler e.g. initBinder() is called on url: "/update/account" and initBinderOne() on…
3
votes
1 answer

Spring MVC Hibernate Validator TypeMismatch Exception

I'm using Spring MVC with Hibernate validator 4.2.0. have a ValidationMessages.properties on my class path in /WEB-INF/classes/ValidationMessages.properties: typeMismatch.java.lang.Integer=Must specify an integer value. typeMismatch.int=Invalid…
3
votes
1 answer

Spring MVC 3 Controller annotation for onBind() - how to?

I am upgrading from Spring 2.5 to Spring 3.2. I have a MVC Controller that previously extended CancellableFormController. It declared,separately, initBinder() and onBind() methods. I have refactored the Controller to use @Controller annotation, and…
arcseldon
  • 29,753
  • 14
  • 104
  • 117
2
votes
1 answer

How to execute code before @InitBinder validation

I have a program that has a functionality to upload a file and then validate if it's name format is correct and save it to db. In my main controller I am using @InitBinder for validation. @InitBinder("uploadFileForm") protected void…
2
votes
2 answers

Why the @InitBinder method is called for every request?

While I was debugging my Spring Boot application I noticed that methods annotated with @InitBinder are invoked for every incoming request. @InitBinder("categories") public void bindFields(WebDataBinder binder) { …
Mahozad
  • 6,430
  • 9
  • 43
  • 70
1
2 3 4 5