/** * Retrieves the type of the currently used data model. If the field has no * data source then the model type of the converter is used. * * @since 7.1 * @return The type of the currently used data model or null if no data * source or converter is set. */ protected Class<?> getModelType() { Property<?> pd = getPropertyDataSource(); if (pd != null) { return pd.getType(); } else if (getConverter() != null) { return getConverter().getModelType(); } return null; }
/** * Convert the given value from the data source type to the UI type. * * @param newValue * The data source value to convert. * @return The converted value that is compatible with the UI type or the * original value if its type is compatible and no converter is set. * @throws Converter.ConversionException * if there is no converter and the type is not compatible with * the data source type. */ private T convertFromModel(Object newValue, Locale locale) { return ConverterUtil.convertFromModel(newValue, getType(), getConverter(), locale); }
if (getConverter() != null) { try { valueToValidate = getConverter().convertToModel(fieldValue, getModelType(), getLocale()); } catch (ConversionException e) { throw new InvalidValueException( getConversionError(getConverter().getModelType(), e));
/** * Convert the given value from the UI type to the data source type. * * @param fieldValue * The value to convert. Typically returned by * {@link #getFieldValue()} * @param locale * The locale to use for the conversion * @return The converted value that is compatible with the data source type. * @throws Converter.ConversionException * if there is no converter and the type is not compatible with * the data source type. */ private Object convertToModel(T fieldValue, Locale locale) throws Converter.ConversionException { Class<?> modelType = getModelType(); try { return ConverterUtil.convertToModel(fieldValue, (Class<Object>) modelType, getConverter(), locale); } catch (ConversionException e) { throw new ConversionException(getConversionError(modelType, e), e); } }
&& !ConverterUtil.canConverterPossiblyHandle(getConverter(), getType(), newDataSource.getType())) {
|| getConverter() != null)) { repaintIsNotNeeded = false;