p:commandButton或p:带有actionListener和结果的按钮? [英] p:commandButton or p:button with actionListener and outcome?
问题描述
我正在使用PrimeFaces并有一个Save按钮,基本上是一个maintenanceTask被发送到我的页面,我在这里编辑它,然后按Save,它应该保存到数据库然后重定向到原始页面。我有一个工作的Save方法,但似乎无法同时启动导航和方法。
I'm using PrimeFaces and have a Save button, basically a maintenanceTask is sent to my page, I edit it within here, then press Save and it should be saved to the database and then redirected to the original page. I have a working Save method, but can't seem to get both the navigation and method to fire off.
<p:commandButton value="#{message.commonButtonSave}"
title="#{message.commonSaveTooltip}"
rendered="#{maintenanceTaskEnquiryBean.screenMode == 'editTasks'}"
disabled="#{maintenanceTaskEnquiryBean.outstandingEditCount != 0}"
action="/definemaintenance/MaintenanceTasksActivity"
actionListener="#{maintenanceTaskEnquiryBean.save}" >
</p:commandButton>
我现在有什么,但我尝试了很多不同的变化,包括p:按钮和p:commandButton,listener / actionListener,target / outcome / action等...
There is what I have at the minute, but I have tried many different variations on this including p:button and p:commandButton, listener/actionListener, target/outcome/action etc...
有任何建议吗?
谢谢。
推荐答案
如果您想要执行操作并在之后导航,请使用操作
属性并返回导航规则。
If you want to perform action, and navigate afterwards, use action
attribute and return the navigation rule as a result.
<p:commandButton value="#{message.commonButtonSave}"
title="#{message.commonSaveTooltip}"
rendered="#{maintenanceTaskEnquiryBean.screenMode == 'editTasks'}"
disabled="#{maintenanceTaskEnquiryBean.outstandingEditCount != 0}"
action="#{maintenanceTaskEnquiryBean.save}">
</p:commandButton>
save()
方法看起来像什么像这样
The save()
method would look something like this
public String save() {
// perform whatever you need to, and then
return "<some navigataion rule>";
}
返回字符串应该打开所需的页面 / definemaintenance / MaintenanceTasksActivity
。
The return string should open the desired page /definemaintenance/MaintenanceTasksActivity
.
这篇关于p:commandButton或p:带有actionListener和结果的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!