Currently serving army now, so my SCJD assignment progress is delayed. Anyway, I have a little issue here.
I got the Bodgitt & Scarper assignment. I'm implementing RMI, and one of the remote methods will allow me to retrieve the database schema (the column names). This will allow me to prevent hardcoding of column names into the client GUI model.
I have a "Book" button at the bottom of the GUI. I will like to implement a tiny effect, where this button will self-disable when the user selects a record which has already been booked. This will prevent them from attempting to book an unavailable record. The problem now is, in my listener code, I have to check the model and see if a customer ID exists for the selected row. If there is a customer ID, that means the record has been booked, and vice versa. It seems that the only way I can check is to hardcode the index of the customer ID column (in my case, 5).
Is this a good way to do things? I mean, I get the schema from the server, yet in my GUI, I assumed that the customer ID is index 5. This seemed contradictory, but I can't think of other ways to get this right. Any suggestions? Or am I in the wrong direction?
PS: Ok I just searched the forum for similar queries. It seemed that there is no way to prevent this. No matter what you do, you have only 2 choices:
i) Hardcode the column name, and search for the index using that name.
ii) Hardcode the index.
So do I conclude that there's no way to prevent hardcodings?
[ November 12, 2005: Message edited by: Liang Anmian ]