3

我正在使用“FeedbackLabels”来显示特定于组件的验证消息,基于此博客文章中的想法和代码:使用 Wicket 进行用户友好的表单验证

问题是,使用此类 FeedbackLabels 验证消息的页面会在日志中充斥着多余的警告:

2012-05-04 10:43:32,824 ["http-bio-8080"-exec-6] WARN  org.apache.wicket.protocol.http.WebSession - Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page.  Message: [FeedbackMessage message = "Tilille on pakollinen tieto", reporter = toAccount, level = ERROR]
2012-05-04 10:43:32,824 ["http-bio-8080"-exec-6] WARN  org.apache.wicket.protocol.http.WebSession - Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page.  Message: [FeedbackMessage message = "Tililtä on pakollinen tieto", reporter = fromAccount, level = ERROR]
2012-05-04 10:43:32,824 ["http-bio-8080"-exec-6] WARN  org.apache.wicket.protocol.http.WebSession - Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page.  Message: [FeedbackMessage message = "Viitenro on pakollinen tieto", reporter = reference, level = ERROR]
2012-05-04 10:43:35,039 ["http-bio-8080"-exec-6] WARN  org.apache.wicket.protocol.http.WebSession - Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page.  Message: [FeedbackMessage message = "Tilille on pakollinen tieto", reporter = toAccount, level = ERROR]
[...]

检票口声称:

未呈现针对组件的反馈消息。这可能是因为您在页面上缺少反馈面板。

问题是,正如您在屏幕截图中看到的那样,这些消息呈现(在每个字段随附的 FeedbackLabels 中),并且我页面上也有一个 FeedbackPanel(但它使用 ComponentFeedbackMessageFilter 过滤以组件为目标的消息,以便它们没有显示两次)。

在此处输入图像描述

无论如何,这些日志消息显然没有用。我怎样才能让 Wicket 闭嘴?(不诉诸暴力方法,例如将日志记录级别更改为 FATAL。)是否应该在 Daan 的 FeedbackLabel 实现中修复某些内容(见下文)?


附录:基本上FeedbackLabel(扩展标签)检查相关组件是否有反馈消息,如果有,显示它。如果您不介意从文章中加载代码,这里是相关部分:

// (Author of this code is Daan, StuQ.nl
// it's licenced under Apache 2.0 license.)
@Override
protected void onBeforeRender() {
    super.onBeforeRender();

    if(component.getFeedbackMessage()!=null) {
        if(this.text!=null) {
            setDefaultModel(this.text);
        } else {
            setDefaultModel(new Model(component.getFeedbackMessage().getMessage()));
        }

        this.add(new AttributeModifier("class", true, new Model("feedbackLabel " + component.getFeedbackMessage().getLevelAsString())));
    } else {
        setDefaultModel(new Model(""));
    }
}
4

1 回答 1

2

FeedbackMessage 有一个 markRendered() 函数。我会为添加到标签的每条消息添加一个调用。请参阅反馈面板的代码。

于 2012-05-04T10:02:05.823 回答