TextChangeListener in Liferay Portlet?

Hi,

I’m developing a Vaadin portlet for Liferay that has a TextField with a TextChangeListener. The idea is to narrow down the records in a Table instantly based on what the user types. This works fine when I’m deploying the application as a servlet, but as a portlet, I have to refresh it before I see the change.

Is there a way to get this to work?

Thanks

Okay, something I discovered is that, if I use setImmediate(true) on my search TextField, then the TextChangeListener code will be called if I type something and then switch to another tab in my browser. So it seems like this can work the way I want(instantly, without having to send a portlet request), but it’s behaving strangely right now.

Any ideas?

Here’s my test code:

package com.example.portlettest;

import com.vaadin.Application;
import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.ui.*;

public class PortlettestApplication extends Application {
	@Override
	public void init() {
		Window mainWindow = new Window("Portlettest Application");
		setMainWindow(mainWindow);
		mainWindow.setImmediate(true);
		
		Label label = new Label("Hello Vaadin user");
		mainWindow.addComponent(label);

		final Label testLabel = new Label();
		testLabel.setImmediate(true);
		mainWindow.addComponent(testLabel);
		
		TextField searchField = new TextField();
		searchField.setImmediate(true);
		mainWindow.addComponent(searchField);
		
		searchField.addListener(new TextChangeListener() {
			public void textChange(TextChangeEvent event) {
				System.out.println("text changed");
				testLabel.setCaption(event.getText());
			}
		});

	}

}

Thanks

Okay, now this: all I have to do to get the TextChangeListener code to activate is to hit enter after I type… still, the idea is for the user to simply type the search term without having to hit enter… it seems like there should be some simple solution to this.

Anything?

Thanks

Hi,

I made a quick test with Liferay and the TextChangeListener does not seem to work. This looks like a bug,
#6825
to be exact.

Marko,

Okay. Thanks for taking the time to look at this.

saw the same issue…

Hi,

It tried to reproduce the issue, but the example provided by magi worked just fine for me so I closed the ticket. I’d bet this is classical non-updated widgetset issue that happens quite easily with Liferay.

I’d suggest to download the Liferay control panel and use it to ensure you have your client side engine properly updated:
http://vaadin.com/directory#addon/vaadin-control-panel-for-liferay

In case you still find out a problem, please add more details to the ticket so we can reproduce it and reopen the ticket.

cheers,
matti

I got the same problem today.

It seems that vaadin embedded in Liferay doesn’t manage to do it.

I upgraded my vaadin-control panel. I replaced all vaadin.jar package in Liferay by the 6.5.2 jar i use.
And i changed widgetset and Gwt libs with http://vaadin.com/download/release/6.5/6.5.2/ files.

After recompiling widgetset using vaadin liferay control panel, it works.

Yep, upgrading to the latest version of vaadin.jar in Liferay did the trick for me.

Cheers

I got the same issue but I am using the 6.6.0.pre1 version of Vaadin.
When I compile with the control panel, I get these errors :

Compiling module com.vaadin.portal.gwt.PortalDefaultWidgetSet
Validating newly compiled units
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/com/google/gwt/editor/client/EditorDriver.java'
[ERROR]
 Line 20: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR]
 Line 97: ConstraintViolation cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/com/google/gwt/editor/client/impl/AbstractSimpleBeanEditorDriver.java'
[ERROR]
 Line 28: Name clash: The method setConstraintViolations(Iterable>) of type BaseEditorDriver has the same erasure as setConstraintViolations(Iterable>) of type EditorDriver but does not override it
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/com/google/gwt/editor/client/impl/BaseEditorDriver.java'
[ERROR]
 Line 31: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR]
 Line 67: ConstraintViolation cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/com/google/gwt/editor/client/impl/SimpleViolation.java'
[ERROR]
 Line 25: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR]
 Line 40: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 43: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 44: Missing code implementation in the compiler
[ERROR]
 Line 49: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 49: Missing code implementation in the compiler
[ERROR]
 Line 70: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 72: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 73: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 77: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 81: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 89: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 93: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 98: ConstraintViolation cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/com/google/gwt/editor/client/testing/MockSimpleBeanEditorDriver.java'
[ERROR]
 Line 26: The import javax.validation.ConstraintViolation cannot be resolved
[ERROR]
 Line 35: The type MockSimpleBeanEditorDriver must implement the inherited abstract method EditorDriver.setConstraintViolations(Iterable>)
[ERROR]
 Line 107: Name clash: The method setConstraintViolations(Iterable>) of type MockSimpleBeanEditorDriver has the same erasure as setConstraintViolations(Iterable>) of type EditorDriver but does not override it
[ERROR]
 Line 108: ConstraintViolation cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/javax/validation/super/javax/validation/Configuration.java'
[ERROR]
 Line 93: TraversableResolver cannot be resolved to a type
[ERROR]
 Line 105: ConstraintValidatorFactory cannot be resolved to a type
[ERROR]
 Line 182: TraversableResolver cannot be resolved to a type
[ERROR]
 Line 182: No source code is available for type TraversableResolver; did you forget to inherit a required module?
[ERROR]
 Line 194: ConstraintValidatorFactory cannot be resolved to a type
[ERROR]
 Line 194: No source code is available for type ConstraintValidatorFactory; did you forget to inherit a required module?
[ERROR]
 Line 202: ValidatorFactory cannot be resolved to a type
[ERROR]
 Line 202: No source code is available for type ValidatorFactory; did you forget to inherit a required module?
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/javax/validation/ConstraintViolationException_CustomFieldSerializer.java'
[ERROR]
 Line 30: ConstraintViolationException cannot be resolved to a type
[ERROR]
 Line 34: ConstraintViolationException cannot be resolved to a type
[ERROR]
 Line 34: No source code is available for type ConstraintViolationException; did you forget to inherit a required module?
[ERROR]
 Line 39: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 39: ConstraintViolation cannot be resolved to a type
[ERROR]
 Line 40: ConstraintViolationException cannot be resolved to a type
[ERROR]
 Line 44: ConstraintViolationException cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/javax/validation/super/javax/validation/MessageInterpolator.java'
[ERROR]
 Line 21: The import javax.validation.metadata cannot be resolved
[ERROR]
 Line 66: ConstraintDescriptor cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/javax/validation/super/javax/validation/constraints/Pattern.java'
[ERROR]
 Line 30: The import javax.validation.Constraint cannot be resolved
[ERROR]
 Line 31: The import javax.validation.Payload cannot be resolved
[ERROR]
 Line 49: Constraint cannot be resolved to a type
[ERROR]
 Line 49: The attribute validatedBy is undefined for the annotation type Constraint
[ERROR]
 Line 75: Payload cannot be resolved to a type
[ERROR]
 Errors in 'jar:file:/C:/my-liferay/dev/bundles/tomcat-6.0.29/webapps/ROOT/WEB-INF/vaadin/gwt/gwt-user.jar!/javax/validation/super/javax/validation/spi/ConfigurationState.java'
[ERROR]
 Line 22: The import javax.validation.ConstraintValidatorFactory cannot be resolved
[ERROR]
 Line 24: The import javax.validation.TraversableResolver cannot be resolved
[ERROR]
 Line 93: ConstraintValidatorFactory cannot be resolved to a type
[ERROR]
 Line 107: TraversableResolver cannot be resolved to a type
Computing all possible rebind results for 'com.google.gwt.user.client.UserAgentAsserter'
Rebinding com.google.gwt.user.client.UserAgentAsserter
Checking rule
[WARN]
 Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
Rebinding com.google.gwt.user.client.UserAgentAsserter
Checking rule
[WARN]
 Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
Rebinding com.google.gwt.user.client.UserAgentAsserter

[...]


Is that because of my vaadin.jar version, or does it come from somewhere else ?

I reply myself : I just downloaded the 6.6.0 release and I had to add the following dependencies :

  • validation-api-1.0.0.GA.jar
  • validation-api-1.0.0.GA-sources.jar

Then it compiled.
But still my TextChangeListener is not working … I don’t know why yet.