不处理数据的PrimeFaces CommandButton [英] PrimeFaces CommandButton that Doesn't Process Data

查看:64
本文介绍了不处理数据的PrimeFaces CommandButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSF/PrimeFaces表单页面,用于编辑一些配置详细信息.底部是实现为CommandButton的Submit和Cancel按钮.取消按钮如下所示:

I have a JSF/PrimeFaces form page set up to edit some configuration details. At the bottom are Submit and Cancel buttons implemented as CommandButton. The Cancel button looks like this:

<p:commandButton
        action="priorPage.xhtml?faces-redirect=true"
        value="Cancel" />

问题在于,视图bean仍然比我想要的对输入到表单中的数据进行更多的处理.它并没有更新数据库中的任何内容,但是如果(例如)我在要在Bean中寻找数字的字段中输入一个字符串,它仍然会产生错误.

The problem is that the view bean still winds up doing more processing on the data that's been entered into the form than I'd like. It isn't updating anything in the database, but if (say) I enter a string into a field that's looking for a numeric in the bean, it still produces errors.

我的解决方案的一部分当然是让Bean优雅地处理这类不良数据,而我正在对此进行研究.但我也想调整该按钮,以便将用户带到上一页.我可以设置一些属性来完全阻止处理表单吗?

Part of my solution is, of course, to get the bean to gracefully handle that sort of bad data, and I'm working on it. But I'd also like to tweak that button so that it just takes the user to the prior page. Is there some attribute I can set that will prevent the form from being processed at all?

推荐答案

<p:commandButton>提交表单.您不想提交表格.然后,您不应使用<p:commandButton>,而应使用<p:button>.

The <p:commandButton> submits the form. You don't want to submit the form. You should then not use the <p:commandButton>, but just <p:button>.

<p:button value="Cancel" outcome="priorPage.xhtml" />

另请参见:

  • h:button和h:commandButton之间的区别
  • See also:

    • Difference between h:button and h:commandButton
    • 这篇关于不处理数据的PrimeFaces CommandButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆