Hi,
I have the following code that seems to be working for TextFied:
TextField tf = (TextField)componentsFactory.createComponent(TextField.NAME);
//MaskedField tf = (MaskedField)componentsFactory.createComponent(MaskedField.NAME);
tf.setDatatype(Datatypes.getNN(Date.class));
tf.setWidth("82px");
//tf.setMask("##/##/####");
tf.addValidator(new com.haulmont.cuba.gui.components.validators.DateValidator());
tf.setDatasource(claimLineTable.getItemDatasource(entity), "serviceDate");
Here the property ‘serviceDate’ is of type java.util.Date in the JPA entity. For TextField, this code seems to be working just fine, however, as soon as I replace TextField with MaskedField, I start getting exceptions from Cuba when it tries to extract the date-data from the field.
Here’s a small snippet from the Stack trace:
... 43 more
Caused by: java.lang.ClassCastException: java.sql.Date cannot be cast to java.la
ng.String
at com.haulmont.cuba.web.gui.components.WebMaskedField.getValue(WebMaske
dField.java:62)
at com.haulmont.cuba.web.gui.components.WebMaskedField.getValue(WebMaske
dField.java:25)
at com.haulmont.cuba.web.gui.components.WebAbstractField.lambda$attachLi
stener$6f56ebaa$1(WebAbstractField.java:258)
Thanks in advance,
Syed
PS. I am using 2.3 RC2 for testing…