jgu*_*emv 5 ajax jsf richfaces ajax4jsf
每个行都有一个带有ah:selectOneMenu的数据表.我希望能够检索bean中selectOneMenu中选择的值.我正在使用richfaces a4j:support标签来对辅助bean进行AJAX调用.你可以看到下面的代码:
<t:dataTable id="datatable" var="row" value="#{myBean.dataTableRows}">
Run Code Online (Sandbox Code Playgroud)
<h:selectOneMenu id="type" label="Type:" styleClass="tamanho80"
value="#{datatableHolder.selectedValue}" converter="comboConverter" immediate="true" >
<f:selectItem itemValue="#{null}" itemLabel="" />
<t:selectItems var="tp"
itemValue="#{tp}" itemLabel="#{tp.nome}"
value="#{row.comboTypeValues}" />
<f:attribute name="row" value="#{row}"/>
<a4j:support event="onchange" reRender="parent" actionListener="${myBean.executeAjax}" immediate="true" ajaxSingle="true" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
public void executeAjax(ActionEvent event){
ValueHolder comboBox = (ValueHolder) event.getComponent().getParent();
comboBox .getValue();
}
Run Code Online (Sandbox Code Playgroud)
PS:
这个问题已被确定为可能与此问题重复,但事实并非如此.我的问题使用dataTable并且不对每个元素使用绑定.另外,我使用的是JSF 1.1和RichFaces 3.3.3.
问题已确定:
t:selectItems 标记生成的每个“选项”都带有项目 id 而不是索引,而comboConverter 使用索引来选择项目。因此,列表有 12 个项目(索引范围应为 0 到 11),但所选项目的 id 为 22。然后转换器将遍历列表到索引 22 并检索元素。但是这个列表中没有这样的索引,因为最大值是 12,然后转换器将始终返回 NULL。
对于这个问题,基本上有3种方法可以解决:
由于对系统影响较小,我选择了第一个。
归档时间: |
|
查看次数: |
1070 次 |
最近记录: |