Firefox 3.6.x 的 ComponentFeedbackPanel

发布于 2024-11-29 00:39:31 字数 2337 浏览 0 评论 0原文

下面的代码似乎在我尝试过的所有浏览器上都运行良好,除了 Firefox 3.6.x。

发生的情况是,每次输入无效电子邮件地址时,我都会出现重复的错误消息。这意味着错误消息很快就会向下扩展至页面。

我是否错过了什么,或者这只是 Wicket 或 Firefox 3.6 中的一个错误? (这是 Wicket 1.4.x 的情况 - 我刚刚升级到 1.4.18,希望它能在那里得到修复,我也尝试了一些旧版本的 1.4.x,以及最新的 5.1 RC)。

package com.mycompany;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.form.AjaxFormValidatingBehavior;
import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
import org.apache.wicket.util.time.Duration;

public class HomePage extends WebPage 
{
    private static final long serialVersionUID = 1L;

    public HomePage(final PageParameters parameters)
    {
        add(new FormX());
    }

    private class FormX
        extends Form<Void>
    {
        FormX()
        {
            super("form");
            final TextField<String>      field;
            final ComponentFeedbackPanel feedback;

            field = new TextField<String>("a");
            field.add(RfcCompliantEmailAddressValidator.getInstance());
            field.setRequired(true);
            field.setOutputMarkupId(true);
            feedback = new ComponentFeedbackPanel("b", field);

            feedback.setOutputMarkupId(true);
            add(field);
            add(feedback);
            AjaxFormValidatingBehavior.addToAllFormComponents(this,
                                                              "onkeyup",
                                                              Duration.milliseconds(250));
        }
    }
}

<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
    <head>  
        <title>Wicket Quickstart Archetype Homepage</title>
    </head>
    <body>
        <strong>Wicket Quickstart Archetype Homepage</strong>
        <br/><br/>
            <form wicket:id="form">
                <input class="in" type="text" wicket:id="a"/>
                <label wicket:id="b">[Feedback]</label>
            </form>
    </body>
</html>

The following code seems to work fine on all of the browsers I have tried, except for Firefox 3.6.x.

What happens is that on each key up of invalid email address I get a duplicate error message appearing. This means that the error messages soon expand down the page.

Have I missed something or is it just a bug in Wicket or Firefox 3.6? (this is with Wicket 1.4.x - I just upgraded to 1.4.18 in the hopes that it was fixed there, I also tried some older versions of 1.4.x as well, and the latest 5.1 RC).

package com.mycompany;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.form.AjaxFormValidatingBehavior;
import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
import org.apache.wicket.util.time.Duration;

public class HomePage extends WebPage 
{
    private static final long serialVersionUID = 1L;

    public HomePage(final PageParameters parameters)
    {
        add(new FormX());
    }

    private class FormX
        extends Form<Void>
    {
        FormX()
        {
            super("form");
            final TextField<String>      field;
            final ComponentFeedbackPanel feedback;

            field = new TextField<String>("a");
            field.add(RfcCompliantEmailAddressValidator.getInstance());
            field.setRequired(true);
            field.setOutputMarkupId(true);
            feedback = new ComponentFeedbackPanel("b", field);

            feedback.setOutputMarkupId(true);
            add(field);
            add(feedback);
            AjaxFormValidatingBehavior.addToAllFormComponents(this,
                                                              "onkeyup",
                                                              Duration.milliseconds(250));
        }
    }
}

<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
    <head>  
        <title>Wicket Quickstart Archetype Homepage</title>
    </head>
    <body>
        <strong>Wicket Quickstart Archetype Homepage</strong>
        <br/><br/>
            <form wicket:id="form">
                <input class="in" type="text" wicket:id="a"/>
                <label wicket:id="b">[Feedback]</label>
            </form>
    </body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

触ぅ动初心 2024-12-06 00:39:31

事实证明,您需要使用 而不是标签。

Turns out you need to use <span wicket:id="b"></span> instead of label.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文