问题描述
我正在寻找一种在表单提交后从后备bean更改primefaces命令按钮的update属性的方法.我想要实现的是基于后备bean方法的结果来更新组件ID.
I am looking for a way to change the update attribute of a primefaces command button from the backing bean after the form submit. What i am trying to achieve is to update the component id's based on the results from backing bean method.
例如,我正在尝试使用命令按钮更新表单和咆哮消息,现在,如果后备bean发生了一些错误(不是验证错误),我只需要更新咆哮消息,并且表单应该不会被更新.
For example, i am trying to update the form and the growl message with a command button, now if some error has happened from the backing bean(not validation error), i need to update only the growl message and the form shouldn't be updated.
<p:commandButton value="Finish Editing"
action="#{editBean.finish}" icon="ui-icon-check"
style="width:200px;margin-left:60px;" update=":studentEditForm :messageForm:applyMessages" />
推荐答案
您可以通过 RequestContext#update()
.
You can use the programmatic API via RequestContext#update()
.
public void finish() {
// ...
if (someCondition) {
RequestContext.getCurrentInstance().update("someClientId");
} else {
RequestContext.getCurrentInstance().update("otherClientId");
}
}
别忘了从命令按钮中删除update
属性.
Don't forget to remove the update
attribute from the command button.
这篇关于在Primefaces中动态更改更新属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!