【问题标题】:JSF1.2 - richFaces progressBar - the simple demo is not workingJSF1.2 - richFaces progressBar - 简单的演示不起作用
【发布时间】:2013-07-23 18:26:47
【问题描述】:

我正在尝试使用来自richfaces progressBar 页面的simple demo

当我转到页面时,它正在呈现开始按钮,按下按钮后进度条显示,显示 0% - 而不是计数直到 100 显示-1 就是这样 - 没有计数,什么都没有。
所以这意味着startTimenull - 但通常它应该有按下按钮的时间。

我也用@AutoCreate 和@Out 对3 个变量进行了尝试... 确实不太好用..

系统正在使用 JSF 1.2 和 Seam。

xhtml 看起来像这样:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">

<h:form>
    <a4j:outputPanel id="progressPanel">
        <rich:progressBar value="#{progressBarBean.currentValue}"
            interval="2000" label="#{progressBarBean.currentValue} %"
            enabled="#{progressBarBean.enabled}" minValue="-1" maxValue="100"
            reRenderAfterComplete="progressPanel">
            <f:facet name="initial">
                <br />
                <h:outputText value="Process doesn't started yet" />
                <a4j:commandButton action="#{progressBarBean.startProcess}"
                    value="Start Process" reRender="progressPanel"
                    rendered="#{progressBarBean.buttonRendered}"
                    style="margin: 9px 0px 5px;" />
            </f:facet>
            <f:facet name="complete">
                <br />
                <h:outputText value="Process Done" />
                <a4j:commandButton action="#{progressBarBean.startProcess}"
                    value="Restart Process" reRender="progressPanel"
                    rendered="#{progressBarBean.buttonRendered}"
                    style="margin: 9px 0px 5px;" />
            </f:facet>
        </rich:progressBar>
    </a4j:outputPanel>
</h:form>

bean 看起来像这样:

/**
* 
*/
package org.richfaces.demo.progressBar;

import java.util.Date;

/**
* @author Ilya Shaikovsky
*
*/
@Name("progressBarBean")
public class ProgressBarBean {

private boolean buttonRendered = true;
private boolean enabled=false;
private Long startTime;

public ProgressBarBean() {
}

public String startProcess() {
    setEnabled(true);
    setButtonRendered(false);
    setStartTime(new Date().getTime());
    return null;
}

public Long getCurrentValue(){
    if (isEnabled()){
        Long current = (new Date().getTime() - startTime)/1000;
        if (current>100){
            setButtonRendered(true);
        }else if (current.equals(0)){
            return new Long(1);
        }
        return (new Date().getTime() - startTime)/1000;
    } if (startTime == null) {
        return Long.valueOf(-1);
    }
    else
        return Long.valueOf(101);
}

public boolean isEnabled() {
    return enabled;
}

public void setEnabled(boolean enabled) {
    this.enabled = enabled;
}

public Long getStartTime() {
    return startTime;
}

public void setStartTime(Long startTime) {
    this.startTime = startTime;
}

public boolean isButtonRendered() {
    return buttonRendered;
}

public void setButtonRendered(boolean buttonRendered) {
    this.buttonRendered = buttonRendered;
}
}

谢谢!

【问题讨论】:

    标签: richfaces jsf-1.2 seam2


    【解决方案1】:

    尝试将@Scope(ScopeType.SESSION)@Scope(ScopeType.PAGE) 添加到您的bean 中,看看是否可行。

    【讨论】:

    • 我很确定,我之前已经尝试过但没有成功,这次成功了……奇怪,但是谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 2023-03-10
    • 2012-06-04
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 2015-11-23
    相关资源
    最近更新 更多