-1

I am trying to set the value of <h:selectOneMenu> using the bean setter, but it is not working. Here is my .xml code:

   <h:selectOneMenu value="#{adminActionController.tempBean.selectType}">
      <f:selectItem itemLabel="Check" itemValue="Check" />
      <f:selectItem itemLabel="Cash" itemValue="Cash"/>
      <f:ajax event="change" listener="#{adminActionController.tempBean.changeType}"/>
   </h:selectOneMenu>

And here is my bean code:

protected String selectType;

public String getSelectType() {
    return selectType;
}

public void setSelectType(String selectType) {
    this.selectType = selectType;
}

I tried a lot of ways, but something is still missing. I don't know what. It sets h:inputText values to bean, but I have a problem with dropdown values. Can anybody help me?

V.Rohan
  • 945
  • 2
  • 14
  • 27

1 Answers1

3

Try without immediate="true".And selectOneMenu must be inside h:form.When selectOneMenu is changed,your listener is working,right ?

mstzn
  • 2,881
  • 3
  • 25
  • 37
  • inside h:form thre is :datatable :rowexpansion :selectOneMenu and also my :ajax listener is not hitting onChange event. On same page :inputText it is working(setting values) bt problem with this tag – V.Rohan Sep 12 '12 at 10:33
  • Listener from same bean_____ public void changeType(AjaxBehaviorEvent event) { System.out.println("tempBean:&&&&&&&&&&&&&&&&&&&&&&&&&&"); System.out.println("cubeChanged: " + ((HtmlSelectOneMenu) event.getComponent()).getSubmittedValue()); } – V.Rohan Sep 12 '12 at 10:43
  • try removing AjaxBehaviorEvent as parameter and try . – PermGenError Sep 12 '12 at 10:44
  • without AjaxBehaviorEvent, it should be S.O.P msg in tomcat .. but it is not showing – V.Rohan Sep 12 '12 at 10:51
  • http://stackoverflow.com/questions/6089924/the-fajax-listener-method-in-hselectonemenu-is-not-executed – mstzn Sep 12 '12 at 11:01
  • Try to avoid forms-nesting if you have any. – fareed Sep 12 '12 at 12:04