File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Best way to create a combo-box (editable selectBox)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Best way to create a combo-box (editable selectBox)?" Watch "Best way to create a combo-box (editable selectBox)?" New topic

Best way to create a combo-box (editable selectBox)?

Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130

Is there any "standard" (or at least, somewhat used) method for creating a combo box (input box + selectMenu) in JSF?

I would assume that if the solution is to create a custom component, then this would have been already, but I can't find any examples of such.
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

Do you mean list box?
You can use the selectonemenu for creating combo box.

Krishna Srinivasan
OCAJP 7/8 Exam, 400+ OCPJP Mock Questions
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
My problem with a list box is that you can't manually enter a value. Basically, I need something with the functionality of both a list box and an input text field.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

There's a common way to do it - it's a trick! Even normal GUI's often use this approach:

Basically, you create a text box control and a droplist control and locate them at the same place. By setting up the right event handlers, you move them up or down on the Z axis for the page so that subsequent UI events go into one or the other. Then, on top of that, if the action was a list selection, you'd make its event handler copy the selected text into the text edit box control so that the text box would be the one-stop location for getting results.

You might want to google around for JavaScript or AJAX resources named "DropDownComboList", "ComboBox" or variants on that. And let me know what you find - I might need one myself some day!

An IDE is no substitute for an Intelligent Developer.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Yeah, we are looking for the same thing. And there might be a third part component already out there. But this is probably best done as a custom component, but just Tim explained. I was actually thinking on creating one for RichFaces to adding it to their list of components, just don't have the time for it for a couple weeks.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
roel croonenberghs

Joined: May 28, 2009
Posts: 10
You can use the rich:combobox thing.

Problem is that it displays the values as the siplays. I want the same behaviour as in h:selectonelistbox where de dipley text of an item is different then its value. Anybody any iideas?
I agree. Here's the link:
subject: Best way to create a combo-box (editable selectBox)?
jQuery in Action, 3rd edition