Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: Making name and location data available to UI client

 
Aaron John
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

After much internal debate, I decided to implement my UI to search for names and locations using combo boxes. My problem is how to expose these names and locations to the UI, so that these combo boxes are populated.

My Data class implements the DBMain interface. It contains a reference to SubcontractorFileAccess.java, which does the actual file reading using RandomAccessFile.



Now since SubcontractorFileAccess will be responsible for retrieving a collection of names and locations, how are these values made available to the client, without accessing SubcontractorFileAccess directly? The only way the Data class is accessed is through the DBMain interface, and according to the assignment specification I am not permitted to add new methods to the DBMain interface to get names and locations from the Data layer. I was going to add public methods to the Data class, but I would need a reference to the Data class implementation to access these methods. It is undesirable because my Data class is screaming for it to be accessed via the DBMain interface.

Does anyone have any ideas on how I can retrieve name and location from the Data layer?

Thanks in advance.
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you can either
1. define another interface and have your Data.java class implements both DBMain and the new interface.

2. or in UI call find for all contractors then extract the info that you need to build the combo boxes.
 
Johan den Boer
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

One way to do it could be this scenario :

When retrieving all record from your database I guess you want to display them in a JTable component. Maybe you can use a Map for the locations and names. Maps do not allow duplicate values. Use the Map to display the unique values in your combo box for location and name

suc6

by the way : I passed the exam wit 373/400. I use Jtextfields for my search values.

John
 
Aaron John
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Musab Al-Rawi:
Hi,
you can either
1. define another interface and have your Data.java class implements both DBMain and the new interface.

2. or in UI call find for all contractors then extract the info that you need to build the combo boxes.



Thanks for that. Immediately after I posted my question, I thought about your 2nd idea.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bruintje Beer,

Please check your private messages for an important administrative matter.

Thanks, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic