Jsf 2 JSF selectOneListBox侦听器不';不要被解雇

Jsf 2 JSF selectOneListBox侦听器不';不要被解雇,jsf-2,listener,Jsf 2,Listener,我到处搜索,但找不到问题的答案,所有问题和答案都与selectOneMenu相关。我在我的页面中使用selectOneListbox组件,如下所示 <h:selectOneListbox id="basic" value="#{location.selectedCategory}" style="width: 400px; border: none;" >

我到处搜索,但找不到问题的答案,所有问题和答案都与selectOneMenu相关。我在我的页面中使用selectOneListbox组件,如下所示

<h:selectOneListbox id="basic" value="#{location.selectedCategory}" style="width: 400px; border: none;" >                                                                                   
    <f:selectItems value="#{location.categories}" var="y" itemLabel="#{y.title} (#{y.itemCount})" itemValue="#{y}" />
    <f:ajax listener="#{location.onNodeSelect}"/>
    <f:ajax render="itemsPanel" execute="@this"/>
</h:selectOneListbox>  
这里的问题是,当我选择列表框中的项目时,selectOneListBox中的侦听器不会被触发。也尝试过primeface(3.5)组件,但运气不佳

更新:添加了更多代码

<h:form id="venuForm" prependId="false">
                                                    <legend>2. Choose Venue</legend>
                                                    <div class="control-group">
                                                        <label class="span3" for="Country">Venue</label>

                                                        <div class="controls">
                                                            <h:selectOneMenu value="#{location.selectedLocationId}" id="select01" required="true"
                                                                requiredMessage="Location is a mandatory field" styleClass="span8">
                                                                <f:selectItem itemValue="#{null}" itemLabel="Select Location" noSelectionOption="true" />
                                                                <f:selectItems value="#{location.allLocations}" var="c" itemLabel="#{c.title}" itemValue="#{c.locationId}" />
                                                                <f:ajax listener="#{location.loadCategoriesListner}" render=":itemForm:categoriesPanel" execute="@this" />
                                                                <f:ajax execute="@this" render=":itemForm:itemsPanel" />
                                                            </h:selectOneMenu>
                                                        </div>
                                                    </div>
                                                </h:form>
                                                <h:form id="itemForm" prependId="false">
                                                    <legend>3. Choose Gift</legend>
                                                    <div class="control-group">

                                                        <p:outputPanel id="panel" autoUpdate="true">
                                                            <div style="padding-left: 5px; padding-right: 5px; padding-bottom: 5px; border: none;">
                                                                <p:panel id="categoriesPanel" rendered="#{location.categories != null}" autoUpdate="true" style=" border: none;">
                                                                    <h:selectOneListbox id="basic"  value="#{location.selectedCategory}" style="width: 400px; border: none;">

                                                                        <f:selectItems value="#{location.categories}" var="y" itemLabel="#{y.title} (#{y.itemCount})" itemValue="#{y}" />
                                                                        <f:ajax listener="#{location.onNodeSelect}" render="itemsPanel" execute="@form" event="change"/>
                                                                    </h:selectOneListbox>

                                                                </p:panel>
                                                            </div>
                                                        </p:outputPanel>
                                                        <div class="clear" style="height: 30px;"></div>

                                                        <div style="padding-bottom: 5px; padding-top: 5px;">
                                                            <p:panel id="itemsPanel" style="float: left;" header="Items">
                                                                <ui:repeat value="#{location.items}" var="o" id="itemTable">

                                                                    <div style="width: 170px; height: 200px; margin: auto; float: left; border-style: solid; border-color: #ECE5B6; border-width: thin;">
                                                                        <div style="margin: 5px; padding: 5px;">
                                                                            <div style="margin-bottom: 5px;">
                                                                                <h:outputText value="#{fnc:getTitleTruncateText(o.title)}"  style="margin: 0 auto;  padding: 0 0 20px; color: #9A1326; width: 100px; font-size: 14px; text-align: center;" />
                                                                                <BR />
                                                                            </div>

                                                                            <div style="padding-left: 45px; margin-bottom: 5px;">
                                                                                <h:graphicImage value="http://dev.cdn.abc.com/#{o.imageId}_3.png" id="itemImage" alt="#{o.title}" />
                                                                            </div>
                                                                            <div
                                                                                style="padding: 5px 10px; background-color: #FFC200; margin: 15px auto 0 auto; width: 100px; text-align: center; color: #29000F; border: 1px solid #F2BD00;">
                                                                                <h:outputText value="$ #{fnc:formatDoubleValue(o.salePrice)}" />
                                                                            </div>

                                                                            <div class="clear" style="height: 5px;"></div>
                                                                            <div style="float: left;">
                                                                                <div style="float: left; margin-right: 50px;">
                                                                                    <p:spinner id="itemQty" value="#{o.selectedQty}" size="3" min="1" max="#{o.qtyAvailable}" style="width: 20px;" />
                                                                                </div>

                                                                                <div style="float: right;">
                                                                                    <h:commandButton value="Add" id="addToCartBtn"  rendered="#{o.qtyAvailable > 0 }" actionListener="#{location.addItemToCart(o)}" />
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </ui:repeat>
                                                            </p:panel>
                                                        </div>

                                                        <div class="clear" style="height: 30px;"></div>
                                                        <div style="float: right;">
                                                            <h:commandButton action="#{location.gotoUserDetails}" value="Next" onclick="return(validate());" rendered="#{!empty location.selectedItems}" />
                                                        </div>

                                                    </div>
                                                </h:form>

2.选择场地
地点
3.选择礼物


问题出在转换器上。这个问题可以通过从jsf组件中获取基元类型值(即整数、字符串…)来解决,或者为类创建一个自定义转换器并在组件中引用它(属性:converter)。

问题在于转换器。这个问题可以通过从jsf组件中获取基本类型值(即整数、字符串…)或为类创建自定义转换器并在组件中引用它(属性:转换器)来解决。

你好,NikolaB,尝试了所有方法,但效果不好,我用更多代码更新了这个问题。你好,Nikola,非常感谢您的帮助。但是我尝试了所有方法,我已经用firefox测试过了,firebug控制台没有错误,我甚至重新启动了机器,希望它能工作。但到目前为止还没有好结果。我不知道还能做什么,我可以试试primeface的解决方法吗?primeface需要更改什么?嗨,NikolaB,我更改了
itemValue以获取
y
对象的id,就像这样
itemValue=“#{y.id}”
。你猜怎么着,成功了。我还用了‘’。它现在应该正常工作了。非常感谢你的帮助。真的很感谢。嗨,尼古拉,我尝试了所有的,但是没有用,我用更多的代码更新了这个问题。嗨,尼古拉,真的很感谢你的帮助。但是我尝试了所有的东西,我已经用firefox测试过了,测试中没有错误
<h:form id="venuForm" prependId="false">
                                                    <legend>2. Choose Venue</legend>
                                                    <div class="control-group">
                                                        <label class="span3" for="Country">Venue</label>

                                                        <div class="controls">
                                                            <h:selectOneMenu value="#{location.selectedLocationId}" id="select01" required="true"
                                                                requiredMessage="Location is a mandatory field" styleClass="span8">
                                                                <f:selectItem itemValue="#{null}" itemLabel="Select Location" noSelectionOption="true" />
                                                                <f:selectItems value="#{location.allLocations}" var="c" itemLabel="#{c.title}" itemValue="#{c.locationId}" />
                                                                <f:ajax listener="#{location.loadCategoriesListner}" render=":itemForm:categoriesPanel" execute="@this" />
                                                                <f:ajax execute="@this" render=":itemForm:itemsPanel" />
                                                            </h:selectOneMenu>
                                                        </div>
                                                    </div>
                                                </h:form>
                                                <h:form id="itemForm" prependId="false">
                                                    <legend>3. Choose Gift</legend>
                                                    <div class="control-group">

                                                        <p:outputPanel id="panel" autoUpdate="true">
                                                            <div style="padding-left: 5px; padding-right: 5px; padding-bottom: 5px; border: none;">
                                                                <p:panel id="categoriesPanel" rendered="#{location.categories != null}" autoUpdate="true" style=" border: none;">
                                                                    <h:selectOneListbox id="basic"  value="#{location.selectedCategory}" style="width: 400px; border: none;">

                                                                        <f:selectItems value="#{location.categories}" var="y" itemLabel="#{y.title} (#{y.itemCount})" itemValue="#{y}" />
                                                                        <f:ajax listener="#{location.onNodeSelect}" render="itemsPanel" execute="@form" event="change"/>
                                                                    </h:selectOneListbox>

                                                                </p:panel>
                                                            </div>
                                                        </p:outputPanel>
                                                        <div class="clear" style="height: 30px;"></div>

                                                        <div style="padding-bottom: 5px; padding-top: 5px;">
                                                            <p:panel id="itemsPanel" style="float: left;" header="Items">
                                                                <ui:repeat value="#{location.items}" var="o" id="itemTable">

                                                                    <div style="width: 170px; height: 200px; margin: auto; float: left; border-style: solid; border-color: #ECE5B6; border-width: thin;">
                                                                        <div style="margin: 5px; padding: 5px;">
                                                                            <div style="margin-bottom: 5px;">
                                                                                <h:outputText value="#{fnc:getTitleTruncateText(o.title)}"  style="margin: 0 auto;  padding: 0 0 20px; color: #9A1326; width: 100px; font-size: 14px; text-align: center;" />
                                                                                <BR />
                                                                            </div>

                                                                            <div style="padding-left: 45px; margin-bottom: 5px;">
                                                                                <h:graphicImage value="http://dev.cdn.abc.com/#{o.imageId}_3.png" id="itemImage" alt="#{o.title}" />
                                                                            </div>
                                                                            <div
                                                                                style="padding: 5px 10px; background-color: #FFC200; margin: 15px auto 0 auto; width: 100px; text-align: center; color: #29000F; border: 1px solid #F2BD00;">
                                                                                <h:outputText value="$ #{fnc:formatDoubleValue(o.salePrice)}" />
                                                                            </div>

                                                                            <div class="clear" style="height: 5px;"></div>
                                                                            <div style="float: left;">
                                                                                <div style="float: left; margin-right: 50px;">
                                                                                    <p:spinner id="itemQty" value="#{o.selectedQty}" size="3" min="1" max="#{o.qtyAvailable}" style="width: 20px;" />
                                                                                </div>

                                                                                <div style="float: right;">
                                                                                    <h:commandButton value="Add" id="addToCartBtn"  rendered="#{o.qtyAvailable > 0 }" actionListener="#{location.addItemToCart(o)}" />
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </ui:repeat>
                                                            </p:panel>
                                                        </div>

                                                        <div class="clear" style="height: 30px;"></div>
                                                        <div style="float: right;">
                                                            <h:commandButton action="#{location.gotoUserDetails}" value="Next" onclick="return(validate());" rendered="#{!empty location.selectedItems}" />
                                                        </div>

                                                    </div>
                                                </h:form>