0

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

<a4j: outputPanel id="new"> 

<h:selectOneMenu id="menuID" value="#{myController.count}" immediate="true"> 
<f:selectItem itemLabel="1" itemValue="1" /> 
<f:selectItem itemLabel="2" itemValue="2" /> 
<f:selectItem itemLabel="3" itemValue="3" /> 
<f:selectItem itemLabel="4" itemValue="4" /> 
<f:selectItem itemLabel="5" itemValue="5" /> 
<f:selectItem itemLabel="6" itemValue="6" /> 
<f:selectItem itemLabel="7" itemValue="7" /> 
<f:selectItem itemLabel="8" itemValue="8" /> 
<f:selectItem itemLabel="9" itemValue="9" /> 
<f:selectItem itemLabel="10" itemValue="10" /> 
</h:selectOneMenu></td> 

<div id="popActionButtons"> 
<h:commandLink value="cancel" onclick="return closePoUpWindow(this);" /> 

<c1:ajaxCommandButton id="save" title="Save" 
onclick="return vailidatesav();" 
value="save" validationType="required" 
eventType="click" styleClass="inputButton" /></div> 
</div> 
</a4j: outputPanel>
ziaur25
  • 85
  • 12

2 Answers2

0

Can you just reset the "#{myController.count}" on panel opening? The problem is you put immediate="true" on selectOneMenu, so on the clicking cancel button the form is submitted and all processes like validation, conversion, update model occur in "apply request values" phase. That's why you see the last value. So either you remove immediate="true" from selectOneMenu and put it on cancel button, or must reset "#{myController.count}" on the button click, which opens the panel.

Tudor Zgureanu
  • 725
  • 7
  • 11
0

check the below cases for the problem

1.I think you are using <t:savestate> to this variable count.. If that is the case please remove.
2. Check the constructor of the bean weather u r setting any value for this variable count.

if above are not the case you better use java script I suggest

  1. onload of page set the default value to the dropdown.
  2. Use onclick event to cancel button and call the java function to set the drop box value to 1..
sonorita
  • 771
  • 2
  • 8
  • 20