File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Portals and Portlets and the fly likes Searching using multiple field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Searching using multiple field" Watch "Searching using multiple field" New topic

Searching using multiple field

sahidul karim

Joined: Sep 19, 2006
Posts: 28
I have 10 field as a search option All field are optional,means i can have value for a single field or for any no of fields or it may be a default search.How can i implement this? Can i use if else condition in my code or can i retrieve the result using a single query ? what will be the best option?
Hemant Sharma

Joined: Feb 01, 2007
Posts: 23

Hibernate Criteria Queries is one of the best options to go, when you have multiple search fields.

Thanks & Regards,<br />Hemant K. Sharma
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Yeah, this isn't really Portlet specific, but Hibernate Criteria is the way to go here. A criteria query looks something like this:

Here two properties are set for the user, but it could be 1, or it could be 10. Here's a tutorial on how to use the Hibernate Criteria API:

Using the Hibernate Criteria API

With a portlet, you only need to package the various libraries in the lib folder. The portal server will find them at runtime. That assumes you portal can interact directly with the database.

-Cameron McKenzie
I agree. Here's the link:
subject: Searching using multiple field
It's not a secret anymore!