I have a form with some attribute related to an object. In this object I have a date object and in my form I recover it like a string. Is it possible to fill the date object by the string ?
JSP form declaration :
<form:form method="POST" action="/netmg/controller/device/search/" modelAttribute="device">
JSP with string value :
<tr>
<td class="label"><spring:message code="device.endDate" /></td>
<td class="value">
<form:input path="endDate" cssClass="datepickerMe" />
<form:errors path="endDate" cssClass="errormsg" />
</td>
</tr>
Then I recover it like this in my controller :
/**
*
* @param device
* @param bindingResult
* @param uiModel
* @return
*/
@RequestMapping(method = RequestMethod.POST)
public String findDevicesByCriteria(@Valid @ModelAttribute Device device, BindingResult bindingResult, Model uiModel) {
if (isCriteriaEmpty(device)) {
uiModel.addAttribute("criteriaEmptyWarning", "error_search_criteria_empty");
return ViewConstants.DEVICE_SEARCH_VIEW;
}
List<IDevice> deviceList = identityService.searchDevices(device.getSerialNumber(), device.getOwner(), device.getIpAdress(), device.getInstallDate(), device.getEndDate());
if (deviceList.size() == 0) {
uiModel.addAttribute(WebConstants.NO_RESULT, true);
}
uiModel.addAttribute(WebConstants.DEVICE_LIST, deviceList);
return ViewConstants.DEVICE_SEARCH_VIEW;
}
Do you have any idea to fill the date object attribute ?