wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Wildcard 'any' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Wildcard Watch "Wildcard New topic
Author

Wildcard 'any'

Daniela Ch
Ranch Hand

Joined: Dec 13, 2002
Posts: 96
Hi,
this is from my spec. :
The user must be able to describe enter the string value "any" for the origin, destinatin or both, so as to implement a wildcard-like feature.

My english is not very good, and I am not sure about the "describe enter"
I used comboboxes to select the airports...and the user can 'select' any...Is that ok or he should be able to 'enter' any?
daniela
Aruna Raghavan
Ranch Hand

Joined: May 14, 2002
Posts: 194
I did it the sameway as you did.


Aruna A. Raghavan<br />SCJP, SCJD, SCWCD
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
How is everyone implementing this wildcard with the criteriaFind function anyway?
I see that many are defining their criteriaFind method to recognise the magic value "ANY". When I did the assignment, I rejected this as an ugly solution --- given that "ANY" in the criteriaFind string is equivalent to not having the criterion at all, it is really hard to justify its presence in the criteriaFind API.
Rather, when building the search in the client I would recognise the value "ANY" and simply not add that field to the criteriaFind string. This doesn't only lead to a simpler criteriaFind implementation, it also makes for easier i18n (internationalisation). This "ANY" magic word obviously differs from language to language. It seemed to me therefore that it ought to be the user interface recognising it, not the server.
Obviously, i18n is way outside the scope of the assignment. But whenever I'm getting greater flexibility or elegance without adding any complexity, I take that as a sign that the design has improved.
- Peter
Jai Karuppuswamy
Greenhorn

Joined: Jan 22, 2002
Posts: 11
My criteriaFind implementation is exactly like Peter's.
And in my UI, I made the combo box enabled, so that the user can type in any, if he/she wanted to search all flights. But I am wondering if I should show any as a selectable value in the combo box, instead. I looked at the Java UI guidelines and to me it looks like both are acceptable. Is one option preferred over the other? If yes, why?
Thanks.


If everything is under control, you're going too slow.<br /> Mario Andretti
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 136
I have planned (yet to implement!) to put 'ANY' in the combo box and the user may type in 'ANY' too. But criteriaFind() does not know what is 'ANY'.
The Client will format ANY as an empty ''. The CriteriaFind() would know '' as 'ANY'.
Is this idea acceptable to Peter and others?
Rajesh
Daniela Ch
Ranch Hand

Joined: Dec 13, 2002
Posts: 96
I handle the wildcard value in the gui and only send the selected airport (or empty string) to the facade, then in the facade i construct the criteria...
I wanted to be able to change the wildcard value easely (in the gui) and I did not want the gui to bother with the formating of the database...
it is done in two steps...
bah
i am uploading today
Bernhard Woditschka
Ranch Hand

Joined: Sep 16, 2002
Posts: 89
I choosed the following version:
The CUI combobox includes "any".
This will be translated to null for the models getFlights(String origin, String Destionation)
null values then are simply ommited criteria in the call to criteriaFind() i.e. not present in the query string.
Bern
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Rajesh Rajesh:
The Client will format ANY as an empty ''. The CriteriaFind() would know '' as 'ANY'.
Is this idea acceptable to Peter and others?
It's more relevant whether it's acceptable to the assessors, which it probably is. Is it the most elegant solution? Well, how will you ever find records that contain an empty String? And why have the magic value '' where you can achieve the same effect by simply not including that field in your criteriaFind expression?
- Peter
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
Peter, i have got a question? what if he is saying Origin='ANY' and nothing else . if you are not sending in to the criteriaFind, how will it be going to display the results.
-Aadhi


Aadhi
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by aadhi agathi:
what if he is saying Origin='ANY' and nothing else . if you are not sending in to the criteriaFind, how will it be going to display the results.
My implementation needed no special code whatsoever to deal with this situation. The client would call criteriaFind(""), i.e. with an empty criteria String, and criteriaFind() would return all records in the database because every record would satisfy the criteria supplied (none).
- Peter
Aruna Raghavan
Ranch Hand

Joined: May 14, 2002
Posts: 194
Hi Peter,
I do the search only if at least one criterion is entered. In a real-life app, we don't want to return all database entries, do we?
Aruna.
Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
Is it a requirement to use a combo box? I simply have two text fields for origin and destination where the client can type in the criteria?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Brian Blignaut:
Is it a requirement to use a combo box?
No. It's nice to have, and the assessor may like your UI better if you use them; I don't know. But it's certainly not a requirement. (I used plain text fields, BTW).
- Peter
aadhi agathi
Ranch Hand

Joined: Apr 29, 2002
Posts: 263
tx Peter, i got it!
-Aadhi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Wildcard 'any'
 
Similar Threads
Question on GUI
Incorrect wording in spec's - any suggestions?
How to construct 'String criteria' ? Help!!!
Too many search criteria?
what's a wildcard-like feature?