Foren

Vaadin TextField loses focus when a component is displayed(TextChangeEvent)

Markus Alfter, geändert vor 11 Jahren.

Vaadin TextField loses focus when a component is displayed(TextChangeEvent)

New Member Beiträge: 4 Beitrittsdatum: 06.03.12 Neueste Beiträge
Hello everyone,

I am using Vaadin Portlets (6.8.1) with Liferay (6.1 GA1).

I have a TextField and would like to show a component after a TextChangeEvent.
The component will be displayed if the TextField contains more than two
characters. Less than three characters hide them.

In Firefox, everthing works correctly, but in the IE8 the TextField loses the
focus.

The issue happens only in the liferay enviroment and in the IE8. A plain Vaadin
project in Tomcat works correctly.

I have a code demo here:


package TestFocus.windows;

import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;

public class ApplicationWindow extends Window {

	public ApplicationWindow() {

		final Label label = new Label("result");
		label.setVisible(false);

		final TextField tf = new TextField("search");
		tf.setTextChangeEventMode(TextChangeEventMode.LAZY);
		tf.setTextChangeTimeout(200);
		tf.setImmediate(true);
		tf.addListener(new TextChangeListener() {

			public void textChange(TextChangeEvent event) {

				if (event.getText().length() > 2 ) {
					label.setVisible(true);
				} else {
					label.setVisible(false);
				}
			}
		});

		addComponent(tf);
		addComponent(label);
	}
}


What am I doing wrong? It's a bug? Can someone help me?

Many thanks!

Post in Vaadin Forum
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Inside of your listener can you add a focus call?

((TextField) event.getComponent()).focus();
Markus Alfter, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

New Member Beiträge: 4 Beitrittsdatum: 06.03.12 Neueste Beiträge
Hi David,

thanks for the help.

Your proposal brings no solution. Unfortunately, the problem persists.

Perhaps you have an idea?

Regards,
Markus
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
You did recompile the widgetset using the vaadin controlpanel for liferay?
Markus Alfter, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

New Member Beiträge: 4 Beitrittsdatum: 06.03.12 Neueste Beiträge
Yes I did. The focus is lost at each TextChangeEvent.
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
I think there's going to be too many moving parts here (Liferay, GWT, Vaadin) to come up with any possible solution. I see that your vaadin forum post hasn't gotten any replies, but I believe it's going to be a vaadin issue in the end (although I certainly don't want to toss them under the bus ;-) and your only hope will be some resolution from their end.

Did you try opening an issue on the Vaadin side? The forum is followed by some of the Vaadin folks, but an issue would certainly get their attention. Since you have a working test case that will reproduce the issue, that should be included too.
Markus Alfter, geändert vor 11 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

New Member Beiträge: 4 Beitrittsdatum: 06.03.12 Neueste Beiträge
I will create a issue, Many thanks!

Vaadin Trac #9157
Paul Butenko, geändert vor 10 Jahren.

RE: Vaadin TextField loses focus when a component is displayed(TextChangeEv

Junior Member Beiträge: 38 Beitrittsdatum: 02.07.10 Neueste Beiträge
There is no answer at ticket.
Does anybody solved this problem?

BR,
Paul