如何将 <a4j:ajax> 与 <f:selectItems> 一起使用
How to use <a4j:ajax> with <f:selectItems>
我想编写 ajax 函数并将 selected 值从 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 功能?
您必须将 a4j:ajax 附加到 rich:select 而不是 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>
改为
<f:ajax>
如果您想使用
<a4j:ajax> declare an <a4j:region> and write it down within it.
我想编写 ajax 函数并将 selected 值从 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 功能?
您必须将 a4j:ajax 附加到 rich:select 而不是 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>
改为
<f:ajax>
如果您想使用
<a4j:ajax> declare an <a4j:region> and write it down within it.