I am trying to enable a command button after a progress bar is completed, but when I load the page the commandbutton is already enabled, apart from this it works fine.
I have done some research and a similar issue: commandButton not working when disable=“true” initially But the solution did not worked for me.
What I am doing wrong? Is there something I am missing?
This is 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>
And this is the session scoped managed bean:
public class ProgressBean implements Serializable {
private boolean disabled= true;
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled= disabled;
}
}