This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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
Author

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

Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Hello,

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: 1844

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


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 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: 15665
    
  15

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!


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
roel croonenberghs
Greenhorn

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: http://aspose.com/file-tools
 
subject: Best way to create a combo-box (editable selectBox)?
 
Similar Threads
Combo box that load data automatically when mouse over the combo box
load data automatically when mouse over the combobox
combo boxes and iterator
How to increase the width of JComboBox Display ??
AWT Combo Box