wicket validate textfield inside listview can'

2019-07-24 23:45发布

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);
    }

标签: wicket
1条回答
你好瞎i
2楼-- · 2019-07-25 00:24

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, ...
查看更多
登录 后发表回答