1

当我创建一个应用程序时,我的页面 bean 没有保存在 @FlowScoped 中。默认情况下,我的代码存储在请求范围内:

enter code here 
package com.webage.beans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.flow.FlowScoped;

@ManagedBean(name="flow1")
@FlowScoped(value = "flow1")
public class Flow1Bean implements Serializable {

    public String cusName;
    public String city;
    public String getName() {
        return this.getClass().getSimpleName();

    }

    public String doReturnValue() {

        return "return1";
    }

    /**
     * @return the cusName
     */
    public String getCusName() {
        return cusName;
    }

    /**
     * @param cusName the cusName to set
     */
    public void setCusName(String cusName) {
        this.cusName = cusName;
    }

    /**
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }
}

我的 Xhtml 文件在这里我从页面获取输入并将其存储在页面 bean 中。:

<p>
            <span id="param1FromFlow1">Flow bean
                param1Value:<h:inputText id="input"
                    value="#{flow1.cusName}" /> </span>
        </p>

        <h:outputText value="#{null != facesContext.application.flowHandler.currentFlow}" >
        </h:outputText>

        <p></p>
        <h:commandButton type="submit" value="Next" styleClass="commandButton"
            id="button1" action="flow1a"></h:commandButton>
        <p></p>

以下代码在 flow/flow1.xhtml 文件中返回“false”

<h:outputText value="#{null != facesContext.application.flowHandler.currentFlow}" >
        </h:outputText>
4

1 回答 1

0

Flowscope 是一个 CDI 范围。使用@Named而不是@ManagedBean.

于 2015-12-12T21:19:26.633 回答