MaskedField Date functionality not working..

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.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
        at com.haulmont.cuba.web.gui.components.WebMaskedField.getValue(WebMaske
        at com.haulmont.cuba.web.gui.components.WebMaskedField.getValue(WebMaske
        at com.haulmont.cuba.web.gui.components.WebAbstractField.lambda$attachLi

Thanks in advance,

PS. I am using 2.3 RC2 for testing…

Hi Syed,

Unfortunately, MaskedField is designed to work only with attributes of String type, and this is stated in the docs.

Use DateField with dateFormat attribute to display Date attributes.