voyent
ice:selectOneMenu doesn't change value if initial value was null  XML
Forum Index -> Components
Author Message
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hi there
To make things short, these are the pieces of code
Code:
public class TestController {
 	private String textValue;
 	
 	public String getTextValue() {
 		return textValue;
 	}
 
 	public void setTextValue(String textValue) {
 		this.textValue = textValue;
 	}
 
 	public String setNewValue() {
 		textValue="2";
 		return null;
 	}
 }
 

and
Code:
 <ice:form>
     <ice:selectOneMenu value="#{testController.textValue}">
         <f:selectItem  itemValue="" itemLabel="Choose value ..." />
         <f:selectItem  itemValue="1" itemLabel="Value 1" />
         <f:selectItem  itemValue="2" itemLabel="Value 2" />
     </ice:selectOneMenu>
     <ice:commandButton value="Set new value" action="#{testController.setNewValue}" />
 </ice:form>
 

Now, on the first pageload, if I push the button, nothing happens. If i select Value 1 and push the button, then Value 2 gets correctly selected.
The behavior does not happen with h:selectOneMenu instead of ice:selectOneMenu.

Eduard Korenschi
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


After some investigation this has something to do with the fact that the first f:selectItem has a null itemValue. If I replace it with anything else, it works ok even with ice:selectOneMenu. But I wish it worked correctly from the very beginning, otherwise I lose "required" and "default" behavior.

Eduard
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team