• Post Reply Bookmark Topic Watch Topic
  • New Topic

Base Form for add / edit / delete  RSS feed

 
J Noble
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I have been developing what I intent to be a base class for several forms that will allow the user for adding / editing / deleteing records. These records could be customers, products, suppliers etc.

I have designed a basic form that has an add, edit and delete button. For the add button, I would want to clear all the values in all of the controls (textboxes, combox etc) in preperation for adding a new record.

My question is this. Is this something I should do in the base class OR should it be handled in the classes that will extend from the base class? Perhaps if the controls were datalinked to the data they will clear themselves (I haven't got that far yet so I dont know). I thought maybe I could write code in the base class that could loop through all of the controls and call this from the extended classes.

Hope this makes sense!

J



 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you could do is create a basic form that has a panel for inputting all the record data, a list to select existing records, and create, update and delete buttons. You can then declare protected abstract methods such as saveCurrentRecord(), deleteCurrentRecord(), and clearFields() that get called by the actions defined on the buttons, which just need to be implemented by the concrete forms.
 
J Noble
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephan,

Just to clarify, when you say add a list for selecting records, do you mean something like a JTable. I could then popultae the JTable in the concrete forms???

J
 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you say you want to be able to edit records, so you need a way to select a record to edit. You could use a JList for example.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!