我正在尝试在进度条完成后启用命令按钮,但是当我加载页面时,命令按钮已经启用,除此之外它工作正常。
我做了一些研究和类似的问题: commandButton not working when disable=“true” initially 但解决方案对我没有用。
我做错了什么?有什么我想念的吗?
这是index.xhtml
<p:growl id="growl" />
<h3>Deskarga</h3>
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:commandButton value="Start" type="button"
onclick="pbAjax.start();startButton2.disable();"
widgetVar="startButton2" />
<p:commandButton value="Cancel"
actionListener="#{progressBean.cancel}"
oncomplete="pbAjax.cancel();startButton2.enable();" />
<p:progressBar widgetVar="pbAjax" ajax="true" rendered="true"
value="#{progressBean.progress}" labelTemplate="{value}%"
styleClass="animated" interval="250">
<p:ajax event="complete" listener="#{progressBean.onComplete}"
update="messages"
oncomplete="startButton2.enable();#{progressBean.setDisabled(false)};"/>
</p:progressBar>
<p:separator id="separator2" />
<p:commandButton value="Parseatu" widgetVar="parserButton" ajax="true"
disabled="#{progressBean.disabled}" actionListener="#{progressBean.parseatu()}"
update="growl" />
</h:form>
这是会话范围的托管bean:
public class ProgressBean implements Serializable {
private boolean disabled= true;
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled= disabled;
}
}
答案 0 :(得分:0)
首先,你不能在oncomplete属性中使用bean方法。这应该不起作用
oncomplete="startButton2.enable();#{progressBean.setDisabled(false)};"
如果你想要使用oncomplete属性禁用ProgressBar组件,你应该调用javascript函数。为此,可以在侦听器方法
上使用RemoteCommand或至少更新disabled属性其次
默认情况下,当我加载页面时,命令按钮已经启用,除了 这很好。
CommandButton组件在disabled
中具有false
属性。如果您希望在disabled
true