0

I'm making form with dropdowns, where user have to make first choice, than using ajax next choices appear. It works just fine. But I wanted to add bootstrap formatting for dropodwns, so I installed bootstrap-select. It work also just fine, but when ajax event renders data for next he renders it in a new dropdown, next to still empty bootstrap formated dropdown. Witch, how can you predict, isn't desired action. Here's code from jsf:

<h:selectOneMenu styleClass="bootstrap-select" id="marka" value="#{searchBean.markiID}">
                <f:selectItems value="#{searchBean.listaMarek}" var="c" itemLabel="#{c.marka}"
                               itemValue="#{c.markaID}"/>
                <f:ajax event="change" execute="marka" render="model"/>
            </h:selectOneMenu>

            <h:outputText value="#{msg.carModel}"></h:outputText>
            <h:selectOneMenu styleClass="bootstrap-select" id="model" value="#{searchBean.modelID}">
                <f:selectItems value="#{searchBean.listaModeli}" var="p" itemLabel="#{p.model}"
                               itemValue="#{p.modelID}"/>
                <f:ajax event="change" execute="model" render="liczbaDrzwi"/>
            </h:selectOneMenu>

enter image description here

In backingbean, when user choose smthging from first dropdown, Is generated list of items for second dropdown, and so on. And this is the result of making choice:

enter image description here

As you can see, ajax makes totally new dropdown, instead of filling already existing.

Thanks for any ideas:)

4

1 回答 1

0

JSF Ajax 以这种方式工作......而不是填充已经存在的下拉列表...... jee 服务器发送一个新的 HTML 片段来替换这个下拉代码......也许你可以阅读这个链接来了解 JSF 生命周期...... jsf lifeclycle

您是否尝试使用 primefaces 或 richfaces 而不是 h:selectOneMenu 组件?

这是一个 PrimeFaces 示例,您可以在其中看到当您在另一个下拉列表中选择一个值时如何更新一个下拉列表... pf 示例

于 2013-11-25T07:03:17.333 回答