Firefox 3.6.x 的 ComponentFeedbackPanel
下面的代码似乎在我尝试过的所有浏览器上都运行良好,除了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,您需要使用
而不是标签。
Turns out you need to use
<span wicket:id="b"></span>
instead of label.