| Author |
Setting the default drop-down list value
|
Eugene Abarquez
Ranch Hand
Joined: May 18, 2006
Posts: 211
|
|
Hi, I have a <h:selectOneMenu> that is being populated in the backend by a managed bean. The data are coming from the database, which and I am putting inside a Collection object, which is then bounded to the <h:selectOneMenu> component, like so: My problem is, I have a CLEAR button, that when clicked will set the value of the drop down list to a default value, say SELECT PARTNERS. So for instance, the values in the drop down list are: SELECT PARTNER Partner 1 Partner 2 When the current value of the drop-down is "Partner 2", and the user clicks the CLEAR button, the value will change back to "SELECT PARTNER". I am having a problem on how to this exactly in JSF. Any ideas or suggestions on how to go about this will be greatly appreciated. Thanks in advance.
|
There's so much to learn in this industry, and not everybody has the necessary interest.
|
 |
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
|
|
all you need to do is set the partner property in "edit" bean to "SELECT PARTNER", when the clear button is pressed.
|
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
|
 |
Eugene Abarquez
Ranch Hand
Joined: May 18, 2006
Posts: 211
|
|
Hi Lynette, It worked! Thanks a lot. I stumbled on a different solution, though it's a lot more complicated and a bit of an overkill. I tried getting the ValueBinding of the HtmlSelectOneMenu component and setting it to null. For instance: It seems to accomplish the same result, but yours is way simpler.
|
 |
 |
|
|
subject: Setting the default drop-down list value
|
|
|