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.
An IDE is no substitute for an Intelligent Developer.
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Setting default value to h: selectOneMenu on button click