Questions tagged [spring-mvc-initbinders]

65 questions
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
1 answer

Customize form bean creation process in spring

I have the following bean: public class TerminalAdmin { @Id @Column(name = "admin_id", nullable = false, unique = true) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_id") @SequenceGenerator(name = "user_id",…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
2
votes
1 answer

Spring-MVC using a Converter to load object from path variable, but need to return 404 for unfound

TL;DR - Is there a way to throw an error from a registered type converter during the MVC databinding phase such that it will return a response with a specific HTTP status code? I.e. if my converter can't find an object from the conversion source,…
atani
  • 53
  • 6
2
votes
1 answer

Spring MVC - @ init binder method not called

Hi this is my controller @RequestMapping(value="/home", method = RequestMethod.POST) public String homeSubmit(@Valid LoginForm loginForm , BindingResult bindResult){ if(bindResult.hasErrors() || bindResult.hasFieldErrors() ){ return…
Renganathan V
  • 413
  • 1
  • 9
  • 27
2
votes
1 answer

Spring 4 ControllerAdvice and InitBinder

I'm trying to register a global InitBinder using an @InitBinder annotated method inside a @ControllerAdvice class. package com.myapp.spring.configuration; import org.springframework.web.bind.WebDataBinder; import…
Paul
  • 133
  • 2
  • 9
2
votes
1 answer

Bind a nested Bean to a null if all its properties are empty in Spring MVC

Let's assume I have an Account class, that has a instance variable of Person class. public class Account { private String accountId; private Person person; // getters and setters } public class Person { private String name; // getters…
Spase Markovski
  • 653
  • 1
  • 8
  • 22
2
votes
2 answers

spring mvc one init binder for all controllers

I have 5 controllers and i would like to register an InitBinder to all of them. I know i can add this code to each of them. @InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(StringWrapper.class, new…
Udy
  • 2,492
  • 4
  • 23
  • 33
2
votes
1 answer

PropertyEditor issue with Set type

Using: Spring 3.2 portlet MVC with Liferay 5.2.3 and Tomcat 6.0.18 I'm trying to create a PropertyEditor to convert between Set and String, and back again. I have successfully got Set to String to work without problems. But I can't get…
pjl55
  • 71
  • 2
  • 7
1
vote
0 answers

Making a getAsText() with Date in PropertyEditorSupport and @Initbinder

I need to convert date with pattern "yyyy-MM-dd" to String format "dd.MM.yyyy". Now i have this. Method getAsText() doesn't work meanwhile setAsText working. What i do wrong? DateEditor.java @Component public class DateEditor extends…
1
vote
1 answer

Java bean validation not working with web init binder

I have a controller looks like this: @RestController @RequestMapping(value="/api/events") public class EventController{ @Inject private EventValidator eventValidator; @InitBinder @Qualifier("eventValidatior") private void…
hades
  • 4,294
  • 9
  • 46
  • 71
1
vote
2 answers

view Calendar Objects in thymeleaf forms as date types

I have a user object, and the User is having a field DOB (Date of Birth) I have stored that field as a calendar inside the User BO. Something like this: public class UserBO { private Calendar dateOfBirth; public Calendar getDateOfBirth() { …
user641887
  • 1,506
  • 3
  • 32
  • 50
1
vote
1 answer

Can a method annotated with @InitBinder be marked as static?

Looking at the docs and several examples of @InitBinder online, I never see these methods marked as static. My IDE is claiming they can be marked as static, I don't see any errors while doing so, and conceptually I would think you can mark it this…
riddle_me_this
  • 8,575
  • 10
  • 55
  • 80
1
vote
1 answer

Spring initbinder register multiple custom editor String.class

I have following initBinder in my ControllerAdvice class @InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(String.class, new StringTrimmerEditor(true)); …
Marek Sekyra
  • 175
  • 2
  • 11
1
vote
0 answers

Spring initBinder not invoking CustomDateEditor

I am trying to bind string input form parameter to the date property of a bean using following code. I want to bind the date formatter only to a specific property named registrationDate of the bean User. I have tried various ways to specify the…
ivish
  • 572
  • 11
  • 35
1
vote
2 answers

customize binding request parameters and fileds inside the accepted to controller method bean in spring mvc

I have the following class: public class MyDTO { @NotEmpty private String isKiosk; ... } and following url: http://localhost:1234/mvc/controllerUrl?isKiosk=false and following controller method: @RequestMapping(method =…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710