wicket validate textfield inside listview can't see error message

我是研究僧i 提交于 2019-12-11 08:14:22

问题


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

回答1:


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, ...


来源:https://stackoverflow.com/questions/16930999/wicket-validate-textfield-inside-listview-cant-see-error-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!