posted 12 years ago
I have a table that has three columns and for the second two columns, the user can enter data into one or the other column and the program fills in the data for the other column. That all works, but then I added an observer which is given data from the table when a complete row is entered. I find that I am sending the data once for each row in the table, rather than once for each change in the table.
Here is the basics of my table model listener:
The problem is when I call methods to update the rows in the table.
I know that by setting the values in the column under program control I am firing off my table model listener (I get one even if I comment them out). None of those intermediate results will be correct. What I was hoping was that I could-
Get the user data
Update the table based on the user data
Build the object for the observation
Set the value of the observation (once)
Did I structure this problem wrong? Or do I need some sort of hack like setting a flag before calling the updateWeightPercent() routine and unsetting it when it is finished? I'm leaning that way, but would rather know the right way to handle this sort of thing.
I'm thinking that I have not organized the problem correctly, I'm not exactly sure why I don't end up in some sort of infinite loop where I call the updateWeightPercent and as soon as it updates a row, it calls itself again. But that doesn't happen. Yet the observable does get updated multiple times.