user373201
user373201

Reputation: 11435

wicket validate textfield inside listview can't see error message

I have a listview inside a listview. I have a textfield inside the nested listview.

new ListView<ConfigStructure>("subListView", propertyList) {
                @Override
                protected void populateItem(ListItem<ConfigStructure> item) {
                    ConfigStructure config = item.getModelObject();
                    final TextField<String> configValue = new TextField<>("configValue",new PropertyModel(config, "value"));
                    configValue.setRequired(true);
                    configValue.add(new CustomConfigValidator(config));

                    item.add(configValue);
                }
            });

I have a feedback panel on the page

add(new FeedbackPanel("feedback"));

But i don't see any errors showing up. The values are not getting submitted if I enter a value that does not pass the validation. but i don't see the error messages either.

Inside my CustomConfigValidator, I have the following

@Override
public void validate(IValidatable<String> validatable) {

    //get input from attached component
    final String field = validatable.getValue();

    if(!checkIfValid){
        error(validatable, "Validation failed for " + config.getLabel() + " with value " + field + ",value should satisfy " + validateString);
    }

Upvotes: 1

Views: 1234

Answers (1)

svenmeier
svenmeier

Reputation: 5681

Reader ListView's javadoc:

<strong>WARNING:</strong> though you can nest ListViews within Forms, you HAVE to set the setReuseItems property to true in order to have validation work properly. By default, ...

Upvotes: 2

Related Questions