ComponentFeedbackPanel with Firefox 3.6.x
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>
开发者_如何学C </form>
</body>
</html>
Turns out you need to use <span wicket:id="b"></span>
instead of label.
精彩评论