我想编写ajax函数并将选择的值从select下拉菜单传递给bean。 这就是我所拥有的:
<rich:select id="ctpMeasurementUnits"
value="#{associationBean.selectedMruId}"
defaultLabel="#{msg['classifier.select']}"
requiredMessage="#{msg['classifier.measurementUnitRequire']}"
validatorMessage="#{msg['common.selectIllegalValue']}">
<f:selectItems
value="#{measurementUnitsListBean.allMeasurementUnits}"
var="mru" itemLabel="#{mru.mruName}" itemValue="#{mru.mruId}">
<a4j:ajax event="change" execute="@this" listener="#{associationBean.onSelectChangeMru(mru)}" />
</f:selectItems>
<f:validateRequired />
<rich:validator />
</rich:select>
然而,通过使用这段代码,我收到一个错误:
<a4j:ajax> Unable to attach <a4j:ajax> to non-ClientBehaviorHolder parent
问题:如何使用f:selectItems
下拉菜单中的ajax函数?
答案 0 :(得分:3)
你必须将a4j:ajax附加到rich:select not f:selectItems
<rich:select id="ctpMeasurementUnits"
value="#{associationBean.selectedMruId}"
defaultLabel="#{msg['classifier.select']}"
requiredMessage="#{msg['classifier.measurementUnitRequire']}"
validatorMessage="#{msg['common.selectIllegalValue']}">
<f:selectItems
value="#{measurementUnitsListBean.allMeasurementUnits}"
var="mru" itemLabel="#{mru.mruName}" itemValue="#{mru.mruId}">
</f:selectItems>
<f:validateRequired />
<a4j:ajax event="change" execute="@this" listener="#{associationBean.onSelectChangeMru(mru)}" />
<rich:validator />
</rich:select>
答案 1 :(得分:-3)
将其更改为
<f:ajax>
如果您想使用
<a4j:ajax> declare an <a4j:region> and write it down within it.