1
I build a line <tr>
using Angularjs and JSTL, and within this line I have an element select
where it is travelled by using <c:forEach>
over an enumerator to fill it when the user clicks to insert a new row.
<td><select name='atributos[{{$index}}].atributo' class='text large form-control' ng-model='atributo.tipo' ><option value='' selected><spring:message code='------------'/></option><c:forEach var='tipoAtributo' items='${EnumTipoAtributo}' varStatus='loop'><option value='${tipoAtributo.id}'><spring:message code='${tipoAtributo.label}'/></option></c:forEach></select></td>
But select stays that way:
Look at the first option
, that is, in the element <option value="? object:null ?"></option>
.
When I click to send the form, as there is a validation with a Hibernate annotation, the following error pops up, instead of a message like The Field is required:
Failed to Convert Property value of type java.lang.String to required type com.projecto.enums.Enumtipoattribute for Property attributes[0]. tipo; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @javax.persistence.Column @javax.validation.constraints.NotNull @javax.persistence.Enumerated com.projeto.enums.EnumTipoAtributo for value ? Object:null ? ; nested Exception is java.lang.Illegalargumentexception: No Enum Constant com.projecto.enums.EnumTipoAtributo.? Object:null ?
When returning to the page this element is deleted and leave blank the validation message appears normally to the user in a way that can understand it, but how can I remove this element with value object:null
?
It cannot and does not make sense to convert the value to Enum that this present within that option being that the value to be received is inconsistent, ie the
? object:null ?
.– Giancarlo Abel Giulian