【问题标题】:Multiple h:form in view not working多个 h:form 视图不起作用
【发布时间】: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。

【问题讨论】:

  • 可能与问题无关,但你的&lt;p:selectOneMenu id="subtipo" /&gt;应该封装在h:form
  • 你能给我们一个完整的视图吗?
  • @skuntsel 这是非常基本的一个输入框,三个一个选择菜单和按钮
  • 理想情况下,您的第一个代码块不应该工作。由于表单之外的组件在 ajax 之后无法更新。请检查您的 xhtml 页面中是否还有其他表单标签
  • @Jitesh 我很确定我的视图中只有两个表单,这不是问题

标签: java jsf-2 primefaces


【解决方案1】:

根据评论,您的问题与未封装在&lt;h:form /&gt;内的&lt;p:selectOneMenu id="subtipo" /&gt;有关。

由于您忽略了这一点,因此该菜单值永远不会发布到 bean。可能是您遇到了阻止您的 p:commandButton 操作的验证或处理错误。

【讨论】:

    猜你喜欢
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多