check this out. i got this from QueryByCriteria class
public Criteria buildCriteria (Object anExample) throws Exception{
Criteria criteria = new Criteria();
ClassDescriptor cld = MetadataManager.getInstance ().getRepository
().getDescriptorFor (anExample.getClass ());
FieldDescriptor [] fds = cld.getFieldDescriptions ();
PersistentField f;
Object value;
for (int i = 0; i < fds.length; i++){
f = fds [i].getPersistentField ();
value = f.get (anExample);
if (value != null){
criteria.addEqualTo (f.getName (), value);
}
}
return criteria;
}
change the addEqualTo to addLike accordingly
shibin
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of Mike Young
Sent: Tuesday, July 20, 2004 2:50 PM
To: [EMAIL PROTECTED]
Subject: How to Develop a Search Page using QueryByCriteria
I am trying to develop a search page that allows users to input their
search criteria into a form and after submitting this form the application
will list all records that match the search criteria.
I currently have a form that captures the users input and places it into a
bean. The bean is the same bean that i would use for gettting data from
the table (i.e. it has getters and setters for each column).
Where I need help is in writing a generic class that will build up the
search criteria using addLike for each property of the bean that is not
null without individually calling each of the getters and testing whether
it is null or not before adding its value onto my criteria using addlike.
Could anyone please point me in the right direction on how to acheive
this?
thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
This e-mail and any files transmitted with it are for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or
copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.
Visit us at http://www.cognizant.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]