• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quick question on SelctOneMenu component

 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a SelectOneMenu component, and I bind the selected value to a backing bean as such:

<h:selectOneMenu id="componentselection" value="#{components.choice}">
<f:selectItem itemValue="One" itemLabel="One"/>
<f:selectItem itemValue="Two" itemLabel="Two"/>
<f:selectItem itemValue="Three" itemLabel="Three"/>
</h:selectOneMenu>

I have a submit button adjacent to this which when pressed will call the getChoice() method and update the value of the choice.

However, I'd like to send the selection without needing a submit button.

How do I this? Use a valueChangeListener?

Is there any speedier way :-)

Thanks

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use onchange="this.form.submit();"
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's friendly to allow auto-submit like this as long as no confusion results. However, it's also good practice to include a Submit button next to the menu in case the user switched off JavaScript.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!