【发布时间】:2013-05-29 23:51:31
【问题描述】:
我有一个 p:selectOneMenu 组件以这种方式更新另一个组件:
<h:form id="formaComboInstrumento">
<p:selectOneMenu value="#{CDat.instrumentoSeleccionado}">
<f:selectItem itemValue="" itemLabel="--Selecciona un examen--"/>
<f:selectItems value="#{CDat.mapaInstrumentos.entrySet()}" var="var" itemValue="#{var.key}" itemLabel="#{var.value}" />
<p:ajax listener="#{CDat.cambioComboInstrumento}" update=":subtipo"/>
</p:selectOneMenu>
</h:form>
<p:selectOneMenu id="subtipo" value="#{CDat.mapaInstrumentosSubtipo}" >
<f:selectItem itemValue="" itemLabel="--Selecciona un examen--"/>
<f:selectItems value="#{CDat.mapaInstrumentosSubtipo.entrySet()}" var="var" itemValue="#{var.key}" itemLabel="#{var.value}" />
</p:selectOneMenu>
效果很好。然后我有另一个带有 p:commandButton 的表单用于提交/处理,这样:
<h:form id="formaProcesarAplicacion">
<p:growl id="growl3" sticky="false" life="3000"/>
<p:commandButton value="Procesar aplicacion" action="#{CDat.procesarAplicacion}" update="growl3"/>
</h:form>
不幸的是,最后一个表单从未触及 bean(我知道,因为当我删除第一个表单时,方法/动作 procesarAplicacion 进行处理并显示值),使得无法进行数据处理。
有什么想法、建议吗?
我正在使用 primefaces 3.5、mojarra 2.1.22、tomcat 7 和 Eclipse Juno。
【问题讨论】:
-
可能与问题无关,但你的
<p:selectOneMenu id="subtipo" />应该封装在h:form中 -
你能给我们一个完整的视图吗?
-
@skuntsel 这是非常基本的一个输入框,三个一个选择菜单和按钮
-
理想情况下,您的第一个代码块不应该工作。由于表单之外的组件在 ajax 之后无法更新。请检查您的 xhtml 页面中是否还有其他表单标签
-
@Jitesh 我很确定我的视图中只有两个表单,这不是问题
标签: java jsf-2 primefaces