Skip to content

Commit

Permalink
Merge pull request springframeworkguru#89 from GeorgePatrascan/issue_72
Browse files Browse the repository at this point in the history
Issue 72
  • Loading branch information
springframeworkguru authored Nov 21, 2018
2 parents 7057fc0 + 7a64149 commit af0df51
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Map;

/**
Expand All @@ -27,8 +30,15 @@ public VisitController(VisitService visitService, PetService petService) {
}

@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
public void dataBinder(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");

dataBinder.registerCustomEditor(LocalDate.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException{
setValue(LocalDate.parse(text));
}
});
}

/**
Expand Down

0 comments on commit af0df51

Please sign in to comment.