I created a form based on a form object.
I pre-filled the form object then display it, but some fields are displayed and some other no.
This is an exemple of a field that give problem:
JSP :
<tr>
<td class="label"><a class="required"></a><spring:message code="service.userNumber" /></td>
<td class="value">
<form:select path="userNumber">
<form:option label="" value="" />
<form:options items="${serviceModelList}" itemLabel="description" itemValue="description" />
</form:select>
<form:errors path="userNumber" cssClass="errormsg" />
</td>
</tr>
A part of my Form Object :
@NotEmpty
private String userNumber;
public DeviceRequestForm(IDeviceRequest deviceRequest) {
this.id = String.valueOf(deviceRequest.getId());
this.site = deviceRequest.getSite();
this.category = deviceRequest.getServiceCategory().getDescription();
this.userNumber = deviceRequest.getServiceModelDescription(); //this is not null
this.validator = deviceRequest.getValidator().getUsername();
this.status = deviceRequest.getStatus();
if (deviceRequest.getDeviceModel() != null) {
this.deviceModel = deviceRequest.getDeviceModel().getModel();
}
}
public String getUserNumber() {
return userNumber;
}
public void setUserNumber(String userNumber) {
this.userNumber = userNumber;
}
A part of my controller :
uiModel.addAttribute(WebConstants.DEVICE_REQUEST_FORM, new DeviceRequestForm(deviceRequest));
return ViewConstants.NEW_REQUEST_DEVICE_VIEW;
Aucun commentaire:
Enregistrer un commentaire