I am displaying a output panel on button click, it has an selectonemenu item, by default value 1 is selected, when i change some value and click CANCEL button and reopen output panel, the last selected value is getting displayed. is there any way to display default value "1"... thanks in advance
You can make the XML more readable by using the "Code" button on our message editor.
When a JSF page is displayed or refreshed, the values for the controls in its forms are set to match the values referenced in the backing beans. So to set the default value to "1", set myController.count to 1 before displaying the page.
Aside from that, I should note that I'm pretty sure that "immediate=true" is not a valid attribute for selectOneMenu and that backing beans are Models, not Controllers, so technically "myController" as a bean name is incorrect.
In JSF, your Controllers are part of JSF itself. You only have to create the Model objects and View templates.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Feb 08, 2011
Thanks for your reply Tim,
But how do I set myController.count to 1 everytime when I load the page?
Whenever a page is rendered, the current values of the backing bean (Model) properties are used to set the displayed control values. So to pre-set the control value, set the backing bean property value.
Note that since JSF operates according to Model/View/Controller rules, a page may be re-displayed multiple times, allowing the user to see validation error messages and correct faulty input data.
subject: Setting default value to h: selectOneMenu on button click