0

I have this lines of code, where I can select a skin.

<h:form>
    <h:selectOneMenu id="dropdownSkin"
        value="#{helloBean.currentSkin.name}" defaultLabel="Select a skin.."
        valueChangeListener="#{helloBean.skinValueChanged}">
        <f:selectItems value="#{helloBean.mySkinsSI}" var="c"
            itemValue="#{c.value}" immediate="true" onchange="this.form.submit()" />
    </h:selectOneMenu>
    <br />

    <h:inputText id="name" value="#{helloBean.currentSkin.name}"></h:inputText>
    <br />
    <h:inputText id="tcolor" value="#{helloBean.currentSkin.tcolor}"></h:inputText>
    <br />
    <h:inputText id="bcolor" value="#{helloBean.currentSkin.bcolor}"></h:inputText>
</h:form>

But I debugged it and it never goes into my method:

public void skinValueChanged(ValueChangeEvent e) {
    currentSkin = (Skin) e.getNewValue();
}

Any ideas why?

4ndro1d
  • 2,926
  • 7
  • 35
  • 65

2 Answers2

2

There is no onchange attribute on f:selectItems tag. Migrate your onchange attribute to h:selectOneMenu and this should work.

h:selectOneMenu is generated as HTML select tag, and f:selectItems are option tags. So onchange really should be in select tag.

partlov
  • 13,789
  • 6
  • 63
  • 82
2

Instead of giving on Change in f:selectItems component, try to give onchange="submit()" for h:selectOneMenu component and try. It should work.

arun_kk
  • 382
  • 2
  • 5
  • 14