OutputLink无法在Flow Scope中使用

时间:2016-05-18 07:02:10

标签: jsf

enter image description here

Confirmation.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>

            <h:form>
                 <h:panelGrid columns="2" columnClasses="rightalign,leftalign">
            <h:outputText value="Salutation: "></h:outputText>
            #{registrationBean.salutation}
            <h:outputText value="First Name: "></h:outputText>
            #{registrationBean.firstname}
            <h:outputText value="Age: "></h:outputText>
            #{registrationBean.age}

             <h:outputText value="Email: "></h:outputText>
            #{registrationBean.email}
             <!--
             <h:panelGroup/>
              <h:commandButton value="continue" action="register-return"></h:commandButton>
             <h:commandButton value="back" action="register"></h:commandButton>-->
             <h:outputLink value="register.xhtml">
                 <h:outputText value="back"></h:outputText>
             </h:outputLink>
              </h:panelGrid>
             </h:form>

    </h:body>
</html>

RegistrationBean.java

import java.io.Serializable;
import javax.faces.flow.FlowScoped;
import javax.inject.Named;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author rshingha
 */
@Named
@FlowScoped("register")
public class RegistrationBean implements Serializable {

    private int age;
    private String firstname;
    private String salutation;
    private String email;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getSalutation() {
        return salutation;
    }

    public void setSalutation(String salutation) {
        this.salutation = salutation;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

}

的index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
        <h:commandLink action="register">
            <h:outputText value="Click here to register"></h:outputText>
        </h:commandLink>
        </h:form>
    </h:body>
</html>

功能性:

这里我们从index.xhtml导航到“register”流程范围,包含register.xhtml,register-flow.xml,confirmation.xhtml

从register.xhtml我们导航到confirmation.xhtml。

的问题:

1)我想在confirmation.xhtml中创建一个“后退”输出链接以导航回register.xhtml

<h:outputLink value="register.xhtml">
                 <h:outputText value="back"></h:outputText>
             </h:outputLink>

但是这不起作用,当我点击UI上的“返回”时它会发出以下错误

“WELD-001303:范围类型javax.faces.flow.FlowScoped没有活动的上下文”

有趣的是<h:commandButton>正在发挥作用。

2)为什么我们不能直接在目录中运行文件(“register”)。    它给出了以下错误:    WELD-001303:范围类型javax.faces.flow.FlowScoped没有活动的上下文

我很困惑。请帮帮我?

0 个答案:

没有答案