Background:
In the Data Client
Object[][] search(
String criteria);
Int bookFlight( Object rec, int seats);
Problem:
When the client UI performs a search (calls the search(String criteria) method of the data client), the data client returns Object[][] instead of DataInfo[] because the UI shouldn�t have to know anything about the database implementation. All is well so far.
The problem occurs when a user selects a flight and tries to book a seat (calls the bookFlight method of the data client). Some form of flight identification has to be passed from the UI to the DataClient so that the correct record is updated. Since I only have a table of Objects, how do I know which column contains the flight number? There has got to be a better way of identifying the desired column then hard coding a column index or a column name into the UI.
Here is the idea I came up with to solve this problem.
In the �Object[][] search(String criteria)� method of the DataClient, I load the return array as follows.
therefore, along with the record data, the first row contains column names and the first column contains a reference to the original DataInfo object
My tablemodel subclass essentially hide the first column for displaying purposes but provide an access method (getKeyObj[int row]) to get it.
When the user selects a row and hits the book button, simply call the bookFlight method of the Data Client and pass in MyTableModel.getKeyObj(selectedRow) and the number of desired seats.
Does that solution make sense? Has anyone else encountered this problem? How did you handle it?