0

I am trying to add ajax for a dropdown and I have added the below code in my xhtml but the listner is not getting called once there is a change.

XHTML Code:

<h:selectOneMenu
                            value="#{loginBean.dropDownValue}" itemValue="#{dropDownValue}">
                            <f:selectItem itemValue="****select***" />
                            <f:selectItems value="#{loginBean.testDropDown}"/>
                             <f:ajax event="change" listner="#{loginBean.changeDropDownOne}" render="testDropDownTwoValue" />
                        </h:selectOneMenu>

Method in the bean:

public List<SelectItem> changeDropDownOne() {
        System.out.println("$$$$$$$$$$");
        String dp = getDropDownValue();
        if(dp != null) {
            System.out.println("**********************getTestDropDownTwo********************************"+dp);
            if(dp.equalsIgnoreCase("One")) {
                testDropDownTwo.add(new SelectItem("One - One"));
                testDropDownTwo.add(new SelectItem("One - Two"));
                testDropDownTwo.add(new SelectItem("One - Three"));
                testDropDownTwo.add(new SelectItem("One - Four"));
            } else if(dp.equalsIgnoreCase("Two")) {
                testDropDownTwo.add(new SelectItem("Two - One"));
                testDropDownTwo.add(new SelectItem("Two - Two"));
                testDropDownTwo.add(new SelectItem("Two - Three"));
                testDropDownTwo.add(new SelectItem("Two - Four"));
            }else if(dp.equalsIgnoreCase("Two")) {
                testDropDownTwo.add(new SelectItem("Three - One"));
                testDropDownTwo.add(new SelectItem("Three - Two"));
                testDropDownTwo.add(new SelectItem("Three - Three"));
                testDropDownTwo.add(new SelectItem("Three - Four"));
            }else {
                testDropDownTwo.add(new SelectItem("Four - One"));
                testDropDownTwo.add(new SelectItem("Four - Two"));
                testDropDownTwo.add(new SelectItem("Four - Three"));
                testDropDownTwo.add(new SelectItem("Four - Four"));
            }
        }
        return testDropDownTwo;
    }
PowerStat
  • 3,757
  • 8
  • 32
  • 57
user2727493
  • 144
  • 2
  • 4
  • 15
  • First thing, `listner` should be `listener`... – Alexandre Lavoie Dec 07 '13 at 04:19
  • did that. still not working. – user2727493 Dec 07 '13 at 05:15
  • Instead of `listener` in ajax tag try `valueChangeListener=#{loginBean.changeDropDownOne}"` directly in ``.And there is such attribute as `itemValue` in `selectOneMenu`. And In your ajax listener it should be associated with `AjaxBehaviorEvent` in your `changedropdown` method. – SRy Dec 07 '13 at 05:48
  • Did you put your `` inside a ``? – Mr.J4mes Dec 07 '13 at 06:49
  • How does the testDropDownTwoValue look like? Also add a global and let it be ajax-rendered to be sure not to have any other errors blocking in validation phase. – L-Ray Dec 07 '13 at 08:46
  • @SRy: `valueChangeListener` is the wrong tool for the job. – BalusC Dec 07 '13 at 10:24
  • Possible duplicate of [commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated](https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value) – Kukeltje Apr 28 '19 at 08:34

0 Answers0