databinding number format [message #329124] |
Fri, 13 June 2008 11:13 |
Eclipse User |
|
|
|
Originally posted by: lukas.myslivec.com
Hello,
i am useing jface databinding to bind an int attribute of my to a text
field. But the text field formats the int what i dont like.
for example:
int intVal = 2500
the text field shows "2.500".
could that be disabled?
thanks for any help
/lukas
|
|
|
Re: databinding number format [message #329131 is a reply to message #329124] |
Fri, 13 June 2008 14:33 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
lukas wrote:
> Hello,
>
> i am useing jface databinding to bind an int attribute of my to a text
> field. But the text field formats the int what i dont like.
>
> for example:
>
> int intVal = 2500
> the text field shows "2.500".
>
> could that be disabled?
Conversion can be overridden in several ways:
1) You can call setConverter() on the UpdateValueStrategy that is passed
in when you call DataBindingContext.bindValue(). However, I think that
will effectively eliminate all of the default conversions; not a problem
if that particular binding only ever binds to integer values in the
model, but if it can be something else, you have to handle all the
potential conversions.
2) You can subclass UpdateValueStrategy and override the method
createConverter() which is called to create the default converter if
none is specified via setConverter(). This might be a better option if
you need to apply the special conversion in multiple places and to
bindings that may not always be converting integer values.
Option 1 is simpler if you know for sure your situation is always
integer <-> Text binding.
Hope this helps,
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.04298 seconds