permaculture playing cards
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S Searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S Searching" Watch "B&S Searching" New topic

B&S Searching

Greg Tan

Joined: May 25, 2005
Posts: 2
I'm progressing well with my assignment (B&S v2.1.2) and I'm implementing the user interface for searching.

The assignment specification says that

It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

I was thinking abut having a a JTextField (or JComboBox, which stores search history) next to a search button. Searching with no text in the JTextField would return all records, entering a value into the JTextField would search on both the name and location fields (ie, if the value entered matches either the name OR location then the record is returned in the search results).

I'm not sure whether that would meet the requirement. The requirement states searching on name and/or location.

The alternative would be to have a search dialog where the user could search on both fields independently. I think this is a bit clunkier for a user interface perspective though.

Anyone got any thoughts on this?
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Greg,

your last assumption sounds good. I have a search dialog and let the user enter both name and/or location. As soon as the user entered values in both (name and location) you can let him chose between an AND or OR search.

So the logic behind AND and OR search is something you have to implement. Keep care where it says exactly match.


Bodenstab Oliver
Ranch Hand

Joined: Mar 03, 2005
Posts: 47
Hi Greg,

i have also the B&S. I implemented 2 ComboBoxes with the distinct values of the database for each field + a keyword "any".
If the user select both ComboBoxes with a value other than any, than i use AND.
If the user select one ComboBox with a value other than any, than i only search for this value.

I hope, that help you to go further.

Lara McCarver
Ranch Hand

Joined: Dec 09, 2003
Posts: 118
One reasonable interpretation of the requirement would be that they have to be able to sort by either NAME or by LOCATION, and you also have to support a search on both NAME and LOCATION. What people keep saying on these forums is that as long as you are interpreting the requirements in a meaningful way, it is OK. So my conclusion is, you can support OR searches if you want to, but you don't have to.
I agree. Here's the link:
subject: B&S Searching
It's not a secret anymore!