我有一个<p:commandButton disabled="#{scannerStatus.disabled}" actionListener="#{scannerStatus.activate}" id="button-id"/>
在scannerStatus我有:
private boolean disabled;//加上geters和setter
public void activate() {
this.setDisabled(true);
boolean status = doAnAction(); // This takes some seconds
if (!status) {
doSomething();
} else {
this.setDisabled(false);
}
}
问题是 commandButton 的属性在调用line from方法disabled时不会改变。this.setDisabled(true)activate
我需要几秒钟disabled将 commandButton 的属性变为true.
该disabled属性设置回 false,然后disabled更新 commandButton 的属性。因此,commandButton 中的更新发生在函数结束后。
this.setDisabled(true)在方法中激活时如何更新 commandButton 的属性?
我尝试在
RequestContext.getCurrentInstance().update("button-id");
之后使用,this.setDisabled但它不起作用。