File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Quick question on SelctOneMenu component Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Quick question on SelctOneMenu component" Watch "Quick question on SelctOneMenu component" New topic
Author

Quick question on SelctOneMenu component

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 299
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
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You can use onchange="this.form.submit();"


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14475
    
    7

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Quick question on SelctOneMenu component
 
Similar Threads
CSS for individual selectItem tag
JSF MissingResourceException !!!
Value Change Listener
Can you have condition in <h:selectOneMenu> ?
How to set Default selection in h:selectOneMenu