1

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;
    }

}  
Community
  • 1
  • 1
GorkaElge
  • 33
  • 5

1 Answers1

0

Firstly, You can't bean method in oncomplete attribute. This shouldn't work

oncomplete="startButton2.enable();#{progressBean.setDisabled(false)};"

If besides You want disabled ProgressBar component using oncomplete attribute, You should call javascript function. For this could to use RemoteCommand or at least update disabled attribute on listener method

Secondly.

when I load the page the commandbutton is already enabled, apart from this it works fine.

CommandButton component have disabled attribute in false for default. If You want show disabled put attribute disabled in true

Cesar Miguel
  • 661
  • 1
  • 13
  • 38
  • Thanks you for the answer,I will try using RemoteCommad, I am learning PrimeFaces and I only know the most common elements. – GorkaElge May 28 '13 at 17:23
  • It solved my problem, thank you! But I also had to add a contructor to the bean setting disabled value to true. – GorkaElge May 31 '13 at 14:14