Add ? Table column (field) based on computed value
I am using the Databound Component tutorial against a modified travel schema
How can I provide a table column for an on-the-fly computed value.
I added a current cost and previous cost to a table and compute the difference. I want the difference to be displayed in the second to the end column of the table.
The database field name is "diff"
Can I simply add a table column and call it "diff"? How do I bind that column to the data field which is "dynamic" (not really a fixed field (column) there)?
Is there a tutorial available which uses this type of data output (display)?
Thanks
# 1
I am not exactly sure what you are asking because you talk about an on-the-fly computed value but there is an actual database field?
An alternative is to add a column and put a text field in the column. Add a property to the page (let's call the property difference. Bind the text field in the column to the difference property.
public int difference() {
int diffVal;
Integer currCost = tblDataProvider.getValue(
"BLABLA.CURRENTCOST,
tableRowGroup1.getRowKey()).toString();
... etc ...
rteurn diffVal;
}
}
Some resources:
http://blogs.sun.com/divas/entry/links_in_tables : Shows how to add a calculate a field in a table
http://blogs.sun.com/divas/entry/table_component_sample_project