vendredi 20 février 2015

Error on form, field not empty when reload the page

I made the following code, it is the controller of the form I'm working on.

The problem is when I use bindingResult.haserrors and then I return the view, an error is well displaying, the field seems to be empty but really no I have to delete a character in the field to have a form with all fields empty (the character deleted is not existing, the field stay empty)

It's complicated to explain so don't hesitate to ask me some questions



@RequestMapping(method = RequestMethod.GET)
public String display(Model uiModel) {
uiModel.addAttribute(WebConstants.LINK_SEARCH_FORM, new LinkSearchForm());
return ViewConstants.LINK_SEARCH_VIEW;
}

/**
*
* @param link
* @param bindingResult
* @param uiModel
* @return
*/
@RequestMapping(method = RequestMethod.POST)
public String findLinksByCriteria(@Valid LinkSearchForm link, BindingResult bindingResult, Model uiModel) {
if (isCriteriaEmpty(link)) {
uiModel.addAttribute("criteriaEmptyWarning", "error_search_criteria_empty");
return ViewConstants.LINK_SEARCH_VIEW;
}
if (bindingResult.hasErrors()) {
return ViewConstants.LINK_SEARCH_VIEW;
}
List<ILink> linkList;
linkList = identityService.searchLinks(link.getSite(), link.getLinkType(), link.getInstallDate(), link.getEndDate());
if (linkList.size() == 0) {
uiModel.addAttribute(WebConstants.NO_RESULT, true);
}
uiModel.addAttribute(WebConstants.LINK_LIST, linkList);
return ViewConstants.LINK_SEARCH_VIEW;
}

Aucun commentaire:

Enregistrer un commentaire