• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 28804
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic