I have wicket's AutoCompleteTextField
. To update the model I use 'onblur' event.
And I need to refresh text field after 'onblur' event happens, because there is validation required.
Here is code sample to illustrate the issue
WebPage subclass:
public class TestPage extends WebPage {
private Integer testField;
public TestPage() {
final List<Integer> allowedValues = new ArrayList<Integer>();
for (int i = 0; i < 5; i++) {
allowedValues.add(50 + i * 5);
}
final PropertyModel<Integer> testModel = new PropertyModel<Integer>(this, "testField");
final AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setShowListOnFocusGain(true);
final AutoCompleteTextField<Integer> testInput =
new AutoCompleteTextField<Integer>("testInput", testModel, autoCompleteSettings) {
@Override
protected Iterator<Integer> getChoices(final String input) {
return allowedValues.iterator();
}
};
testInput.setOutputMarkupId(true);
testInput.setMarkupId("testInput");
add(testInput);
testInput.add(new AjaxFormComponentUpdatingBehavior("onblur") {
@Override
protected void onUpdate(final AjaxRequestTarget target) {
target.add(testInput);
}
});
}
}
Corresponding HTML:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" xml:lang="en"
lang="en">
<body>
<input type="text" wicket:id="testInput"/>
</body>
</html>
The problem is that it is impossible to select value by mouse click.
I've tried using OnChangeAjaxBehavior
- and selection by mouse click works, but I don't want to perform validation after every single change (e.g. user wants to type 54, he types 5 => validation starts because OnChangeAjaxBehavior
is fired)
I've tried using combination of both AjaxFormComponentUpdatingBehavior("onblur")
and OnChangeAjaxBehavior
and I had the same problem: can't select value by mouse click, because 'onblur' is fired before 'onchange'
Please note that if you comment the line target.add(testInput);
, it will work as expected.
It seems to be similar to this Wicket issue
It says that issue is fixed for 6.18.0 version, but I use exactly Wicket 6.18.0 and still have this problem.
We've been performing upgrade from Wicket 1.4 to wicket 6. And in Wicket 1.4 it worked fine.
Please give me any advice on how to resolve this issue. Your help will be really appreciated. Thanks in advance.