Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean list box?
You can use the selectonemenu for creating combo box.
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
roel croonenberghs
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic