Textfield value not updated in UI

Hi there,

i created a Textfield which inherted the com.vaadin.ui.TextField.
I did override the Method getValue, to manipulate the shows value in the Textfields in my Form.

In case of leaving the textfield after the text input, the getValue method is called correctly to manipulate the given content.

But only if the textfield is marked as required. If its not required, just nothing happens.
Thats excatly my problem.

Any ideas??

Help would be appreciated :slight_smile:

bye
steffan

Bonjour,
did you set the TextField to react immediately ?
myTextField.setImmediate(true);

Gilles

yes of course i did …

still it’s crazy to achieve my goal i got to make the field required.

:frowning:

Bonsoir,
may you post your code, at least the overidden getValue ?

sure:


	public String getValue() {
		Object valueOrigin = super.getValue();
		if (valueOrigin != null) {
			value =valueOrigin.toString();
			if (isFormatedCurrencyField) {
				value = (String) formatFloatVersion();
			}
		} else {
			value = "";
		}
		return value;

	}

(String) formatFloatVersion(); is formating the output in a certian way. and after the textinput, the textfield is only updated if it is marked as required.

When debugging, one can see that the method is called even if the textfield is not required, but the UI is not updated :slight_smile:

my guess is: its a BUG :wink:

bb
steffan

Bonjour,
if I understand correctly :
1°) you retrieve the non formatted value
2°) you format the retrieved value

but where do you update the TextField with the formatted value, using setValue(value) ?

à bientôt,

You might want to use a PropertyFormatter (or the conversion facilities of the CustomField add-on - the class FieldWrapper from the add-on might also make it easier to attach the converter) instead of this approach. Performing conversions in an overridden getValue() might have various side effects unless you understand all the related mechanisms.

In Vaadin 7, conversion support is built into the framework.