Thursday, August 14, 2014

Vaadin style not being applied to textfield

In Vaadin 6.8.6 I noticed that after declaring a TextField and after adding a style name, in some cases style doesn't apply in textfield.
I noticed that the issue was just on a TextField and I realized that the method "focus" strangely makes the style disappear.


Here is an example:

TextField tf = new TextField();       
tf.setInputPrompt(inputPrompt);
tf.setWidth(width, Sizeable.UNITS_PIXELS);
tf.addStyleName("textfield-roundleft");


tf.focus();  // Makes the style disappear!

The solution I found is to remove the method call tf.focus();

Note: the context was a Liferay Portlet with Vaadin, I can't say if it happens in a normal web application too.

No comments:

Post a Comment

(c) Copyright 2020 - MyTroubleshooting.com