Hi All,
Are there any specific reason that VTextField calls getText() method, when doing server request on value change? Why getValue() method has not been used?
To be more general, in VTextField, why getText and setText methods are use for value retrievent and setting, and not getValue and setValue methods?
Any ideas?
There is no getValue() in the client-side widget VTextField. I hope you are not confusing the client-side widget with the server-side TextField, which has its text value as its property value. There are no equivalent data binding abstractions or other features in the client-side as there is in the server-side.
The getText() is a GWT method that provides direct access to the “value” property of the HTML text input element, as in .
In the client side VTextField; getValue() method is coming from inherited parent class TextBoxBase and setValue() method is coming from inherited parent class ValueBoxBase .
I am using Vaadin 6.6.6 and gwt client version 2.3.0.
the difference between get/setText and get/setValue method is, the latter is using renderer and parser to render and parse the displayed value back and forth. I think, this is a good pattern to follow. By this way, one can do serverside->clientside; clientside->serverside formatting on the client side. And this may be helpfull when value passing between widgets through clientside events without going back to the server when needed.
Anyhow, the TextField value is just text on the client-side so there’s no need to parse it there to some other data type. Vaadin handles the conversion to non-text data types on the server-side.
yeah. you’re right about data type conversions but whatabout formatting . Such as masking, number formating etc.
do we really need to go to server for such simple client side painting issues?
It would not be
really needed to go to the server for such tasks, at least for number formatting, but that’s part of Vaadin’s server-side programming model that makes it easier to use. Otherwise, you’d always have to write client-side code to get numbers formatted/parsed, and then probably do it also on the server-side anyhow for security, etc. It’s also easier to send just strings to the server-side instead of object types, which would have to exist on the client-side if the input was parsed there.
Some tasks, such as masking, are not possible or at least feasible with server-side code. That’s probably why there are so many TextField-related add-ons, such as MaskedTextField and CSValidation.
In the latest version of
IkarusWidget addon , IkarusTextField uses parser/renderer mechanism. vaadins textfield has been changed to support this structure. Now, IkarusnumberField and IkarusMaskField are extending IkarusTextField and uses their own renderer and parser for clientside formatting. With this implementation; at clientside; set/getText directly deals with the value inside dom element (direct accessread/write to element ) whereas set/getVallue uses parser/renderer to parse/render serverside value and used for serverside communication.