• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bruintje Beer,

Please check your private messages for an important administrative matter.

Thanks, Andrew
 
reply
    Bookmark Topic Watch Topic
  • New Topic