PropertyFormatter not called

I have a textfield where I have added a RegexpValidator as the validator and I have set the PropertyDataSource to an derived class of PropertyFormatter. When I enter text into the textfield the validator gets called, but my PropertyFormatter is never called and thus not formatted.

Does anyone have an idea of what could be wrong?

A snippet of my code:

public class HomeRatesForm extends Form {
    public HomeRatesForm(HomeRates homeRates) {
        setFormFieldFactory(new CurrencyFormFieldFactory());

        BeanItem<HomeRates> dataSource = new BeanItem<HomeRates>(homeRates);


    private void attachCurrencyFormatter() {
        Field domesticRate = getField("domesticRate");
        domesticRate.setPropertyDataSource(new CurrencyFormatter(currency, domesticRate.getPropertyDataSource()));

The CurrencyFormFieldFactory creates CurrencyTextFields.

The CurrencyFormatter

public class CurrencyFormatter extends PropertyFormatter {
    private static final Logger log = Logger.getLogger(CurrencyFormatter.class);

    private final DecimalFormat currencyFormatter;
    private final String currency;

    public CurrencyFormatter(String currency, Property dataSource) {
        this("#,##0.00## ", currency, dataSource);

    public CurrencyFormatter(String formatString, String currency, Property dataSource) {
        this.currency = currency;
        currencyFormatter = new DecimalFormat(formatString + currency);

    public String format(Object value) {
        try {
            return currencyFormatter.format(value);
        } catch (IllegalArgumentException e) {
            log.error("Could not format value: " + value, e);
        return value.toString();

    public Object parse(String formattedValue) throws ParseException {
        String amount = "";
        Pattern doublePattern = Pattern.compile(CurrencyTextField.regexAmount);
        Matcher m = doublePattern.matcher(formattedValue);
        if (m.find()) {
            amount =;

        Number parsedValue = currencyFormatter.parse(amount + " " + currency);
        return parsedValue.doubleValue();

    public Class getType() {
        return Double.class;

Tested your code quickly and it seems to work for me. The only difference was that I did not have a custom FieldFactory.