【问题标题】:Primefaces commandLink works but not commandButton [duplicate]Primefaces commandLink有效,但commandButton无效[重复]
【发布时间】:2016-08-10 03:04:19
【问题描述】:

我对 commandLink 和 commandButton 有相同的操作。但是,commandLink 按预期工作。但是使用 commandButton 不会发生任何操作。我缺少语法吗?

<p:commandLink value="Submit"  action="#{beanController.getStr(strSearch)}" ajax="false"/>
         <p:commandButton value="Submit"  actionListener="#{beanController.getStr(strSearch)}" ajax="false"/>     

【问题讨论】:

  • 你的意思是没有导航发生吗?如果是这样,您是否打算在您的commandButton 中使用action 而不是actionListener
  • 谢谢,原来如此。现在可以了。

标签: jsf primefaces


【解决方案1】:

如果您打算进行导航,则应在 commandButton 中使用 action 而不是 actionListener,因此:

<p:commandButton value="Submit"  action="#{beanController.getStr(strSearch)}" ajax="false"/>

【讨论】:

  • 谢谢,我正要查找它们之间的区别。我看到了你的回答。
【解决方案2】:

commandButton 按钮生成 HTML &lt;input type="submit"&gt; 元素,commandLink 生成 HTML &lt;a&gt;,comandButton 用于提交表单,而 commandlink 用于提交链接,因此您的表单未提交我建议您检查是否存在任何嵌套表单,或者您的代码中是否存在多个表单或任何其他导致表单提交的问题,然后您可以发布您的代码。

【讨论】:

  • 谢谢,已修改问题
猜你喜欢
  • 2012-05-13
  • 2013-05-22
  • 2013-07-04
  • 2014-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-14
  • 2017-05-08
相关资源
最近更新 更多