启用后,Prime面临命令按钮不起作用

时间:2013-05-26 12:06:28

标签: jsf-2 primefaces

我正在尝试在进度条完成后启用命令按钮,但是当我加载页面时,命令按钮已经启用,除此之外它工作正常。

我做了一些研究和类似的问题: 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;
    }

}  

1 个答案:

答案 0 :(得分:0)

首先,你不能在oncomplete属性中使用bean方法。这应该不起作用

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

如果你想要使用oncomplete属性禁用ProgressBar组件,你应该调用javascript函数。为此,可以在侦听器方法

上使用RemoteCommand或至少更新disabled属性

其次

  

当我加载页面时,命令按钮已经启用,除了   这很好。

默认情况下,

CommandButton组件在disabled中具有false属性。如果您希望在disabled

中显示已停用的放置属性true