Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoCompleteTextFields submits Form if a choice is selected via enter-key #533

Open
cggm80 opened this issue Aug 17, 2016 · 3 comments
Open

Comments

@cggm80
Copy link

cggm80 commented Aug 17, 2016

Copy from WICKET-4857

"I am not quite sure if this is really a bug, but the behaivor of wicket 1.5 and wicket 6 differs in the following situation:
In wicket 1.5 a user could select a choice in an AutoCompleteTextField via the enter-key and the underlying Form was not submitted.
In wicket 6 however the Form gets submitted in that case.
Note: the behaivor is in both versions identical (aka no form submit) if no button is added to the form. Thus in both versions the Form is not submitted if the user selects a choice via mouse-click.
While in some use cases it is useful that hitting the enter-key in TextFields submits the form - e.g. in a search panel, in this particular use case the form should not be submitted. Or at least, there should be a (built in) hook to prevent this behaivor."

I REALIZE migration version 1.4 to 6. In version 1.4 there were no problems.
I currently work with version 6.24 with ObjectAutoCompleteField control and have the error described at the top. I tried in the examples of wicketstuff 7 ObjectAutoComplete exactly Examples - Example Validation and the problem persists.

Any idea to solve described.

@martin-g
Copy link
Member

AFAIK ObjectAutoComplete uses a copy of Wicket-Extensions wicket-autocomplete.js and this file has not been kept up-to-date with the fixes upstream.
You can try to debug the problem and compare the JavaScript functions related to the problem.

@cggm80
Copy link
Author

cggm80 commented Aug 17, 2016

Of course, I'm trying to find the difference in behavior and finding no hope someone can give me an idea. Until commented that implements it with AutoCompleteTextField and does not give the error described by pressing the enter key. But my controls are with ObjectAutoCompleteField.

@cggm80
Copy link
Author

cggm80 commented Aug 17, 2016

By the time, a partial solution was found to definitely fix it through your help. The issue is to know how to prevent the event from spreading to submit.
As you can see, i am being controlled by a variable, but involves a strong change in migration.

//Autocomplete
ObjectAutoCompleteField busca_marca = marcaBuilder.build("txtMarcas", new PropertyModel(this, "marcaId"));
busca_marca.setOutputMarkupId(true);
busca_marca.add(new AjaxFormSubmitBehavior(form_busqueda, "change") {
         @OverRide
           protected void onSubmit(AjaxRequestTarget target) {
               autocomplete = true;
           }
           @OverRide
           protected void onError(AjaxRequestTarget target) {
           }
       });`

//AjaxButton
AjaxButton btn_consultar = new AjaxButton("btn_consultar", form_busqueda) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (_autocomplete_) {                  _autocomplete_ = false;                } else { //Code } }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants