【问题标题】:p:commandButton click updates h:form unwantedlyp:commandButton 点击​​更新 h:form 不必要的
【发布时间】:2018-02-19 05:49:18
【问题描述】:
    <p:commandButton id="excelAccountLevelOneAccLvl1" ajax="false" icon = "fa fa-fw fa-download" >
                        <f:param name="accountLevelOneFormRequest" value="accountLevelOneFormRequest" />
                        <p:dataExporter type="xlsx" target="baselineOneTable"
                            fileName="#{exportToExcelPageBean.fileName}"
                            postProcessor="#{exportToExcelPageBean.postProcessXLS}" />                              
                    </p:commandButton>  

单击此按钮后,表单似乎会以某种方式更新,它会激活 Faces 验证并要求我填写输入必填字段值!我不知道为什么!这里根本没有update参数!

【问题讨论】:

  • 那么,当你删除 Hibernate,或者用 Mojarra 替换 MyFaces,或者用 JSP 替换 XHTML 时,这个问题就消失了?

标签: jsf primefaces


【解决方案1】:

更新仅适用于 ajax 请求。您正在使用 ajax="false" 这意味着 commandButton 激活 整页请求。这反过来意味着包含 commandButton 的整个表单是 处理。如果您想避免这种情况,请将您的 commandButton 放在单独的表单中。

【讨论】:

  • 如此真实!非常感谢! :)
  • @Ajachs:这个答案有效地解释了默认的 jsf 行为。最好通过阅读一个好的教程来掌握它。有助于防止将来出现类似问题。
  • 您不能将 ajax 与 p:dataExporter 一起使用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-05
  • 2011-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多