不处理数据的 PrimeFaces 命令按钮 [英] PrimeFaces CommandButton that Doesn't Process Data
问题描述
我设置了一个 JSF/PrimeFaces 表单页面来编辑一些配置细节.底部是提交和取消按钮,实现为 CommandButton
.取消按钮如下所示:
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?
推荐答案
提交表单.您不想提交表单.然后你不应该使用
,而应该使用
.
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 的区别
这篇关于不处理数据的 PrimeFaces 命令按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!