You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by lello <rb...@gmail.com> on 2010/12/16 17:03:28 UTC

Formatted value and actual data in TextInput

Hi all,

in my application I have a table with a row editor in which TextInput field
displays a number (double precision). When I edit the number I want to have
only three decimal digits, however I need the "exact" data table (the double
precision version) to perform the same other calculation.
The point is: I can easily display the number of digits I want by
implementing a TextInput.TextBingMapping,
however, when the valueOf() method fires in the the table data a rounded
number, and when I retrieve the data from the table I get the wrong values.

Is there any way to separate the displayed formatted numbers of a table from
the actual data contained in the table, when using a TextBindMapping
interface?

-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Formatted-value-and-actual-data-in-TextInput-tp2099149p2099149.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Formatted value and actual data in TextInput

Posted by Greg Brown <gk...@verizon.net>.
> The user doesn't write any new number in the editor, just presses
> enter to exit the roweditor, but the value 3.1490 is stored as the actual
> value of the data.

Ah. Using the default editor, pressing Enter confirms the edit. The user should press Escape to cancel an edit. Then the new value won't be applied.


Re: Formatted value and actual data in TextInput

Posted by lello <rb...@gmail.com>.
I'll try to make it simpler:
Let's say I have 3.1494999. When I first display it in the listview the
(displayed) rounded value is 3.149, 
but the actual value is still
Then a user opens the roweditor (double click on the row or whatever) and
the value 3.149 is displayed in the textinput field. But...hey it was an
error, the user doesn't want to change any number. However here comes the
problem. The user doesn't write any new number in the editor, just presses
enter to exit the roweditor, but the value 3.1490 is stored as the actual
value of the data. So I have lost four significant digits (the 4999 part of
the number). 

This is casued by the toString() method. I think one would need a way to
check if a change has 
actually been made in the table and only in that case call the method.

-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Formatted-value-and-actual-data-in-TextInput-tp2099149p2105075.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Formatted value and actual data in TextInput

Posted by Greg Brown <gk...@verizon.net>.
I'm still not sure I understand the problem. Let's take a simple example. Let's say I have a ListView that displays float values. The first value is 3.14159265. When the user edits this value, I only want to show two decimal places. I have to truncate it somehow, so I take the floor() value: 3.14.

The user changes the value to 3.15. Now I want to go back to 8 decimal places, which would be 3.15000000. Is that what you are trying to do?

On Dec 16, 2010, at 6:02 PM, lello wrote:

> 
> That's exactly the case.
> The problem is the following: I have a table and the values of columns A are
> linked each other by a certain function f(). Now, when I edit one element of
> column A, all the other elements should be updated.
> However, when editing I want to display only 3 significant digits, but the
> real calculation should consider all the significant digits (not the
> displayed rounded value).
> Concrete case: two variables in the table
> A = 38.5;
> B = 11; 
> 
> The ratio A/B must be 3.5. So if I edit A and write 12 I should get
> B=3.428571428571428, which is then 
> displayed with 3 decimal digits as 3.429. Suppose now I want to edit B.
> Double click on B, and just press
> enter, without changing the number. When I press enter the TextInput calls
> store() and valueOf(), which takes the value 3.429 as the "true" value,  and
> set A=3.429*3.5=12.001. 
> If you repeat this type of rounding error on a table after a few cycles you
> get quite useless numbers.
> 
> Is there any way to avoid this problem?
> 
> 
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Formatted-value-and-actual-data-in-TextInput-tp2099149p2101531.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Formatted value and actual data in TextInput

Posted by lello <rb...@gmail.com>.
That's exactly the case.
The problem is the following: I have a table and the values of columns A are
linked each other by a certain function f(). Now, when I edit one element of
column A, all the other elements should be updated.
However, when editing I want to display only 3 significant digits, but the
real calculation should consider all the significant digits (not the
displayed rounded value).
Concrete case: two variables in the table
A = 38.5;
B = 11; 

The ratio A/B must be 3.5. So if I edit A and write 12 I should get
B=3.428571428571428, which is then 
displayed with 3 decimal digits as 3.429. Suppose now I want to edit B.
Double click on B, and just press
enter, without changing the number. When I press enter the TextInput calls
store() and valueOf(), which takes the value 3.429 as the "true" value,  and
set A=3.429*3.5=12.001. 
If you repeat this type of rounding error on a table after a few cycles you
get quite useless numbers.

Is there any way to avoid this problem?


-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Formatted-value-and-actual-data-in-TextInput-tp2099149p2101531.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Formatted value and actual data in TextInput

Posted by Greg Brown <gk...@verizon.net>.
Not sure I fully understand the use case. It sounds like you have a value in a model somewhere that has some number of significant digits (say 10). However, you want to present a smaller number of significant digits to the user (say 3). Then when the user is done editing, you want to go back to 10. Is that right? If so, can you provide a more concrete example?

On Dec 16, 2010, at 11:03 AM, lello wrote:

> 
> Hi all,
> 
> in my application I have a table with a row editor in which TextInput field
> displays a number (double precision). When I edit the number I want to have
> only three decimal digits, however I need the "exact" data table (the double
> precision version) to perform the same other calculation.
> The point is: I can easily display the number of digits I want by
> implementing a TextInput.TextBingMapping,
> however, when the valueOf() method fires in the the table data a rounded
> number, and when I retrieve the data from the table I get the wrong values.
> 
> Is there any way to separate the displayed formatted numbers of a table from
> the actual data contained in the table, when using a TextBindMapping
> interface?
> 
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Formatted-value-and-actual-data-in-TextInput-tp2099149p2099149.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.