我正在编写一个 JSF Web 应用程序,并且我曾经拥有主要的支持 bean 请求范围。后来我把它改成了 session-scoped,现在我需要创建一个新的 request-scoped backing bean。我遵循了我的第一个请求范围 bean 的格式,但我似乎根本无法调用构造函数。我已经使用 JSF 很长一段时间了,但是当我以前有一个请求范围的类工作得很好时,我无法弄清楚为什么它不会调用构造函数。:-S
这是我的支持 bean 类:
package brian.canadaShipping;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean(name= "cpstcRequestBean")
@ViewScoped
public class CpstcRequestBean implements Serializable {
private static final long serialVersionUID = -5066913533772933899L;
public CpstcRequestBean()
{
super();
System.out.println("Hello, RequestBean!");
}
}
这是我的 faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>home</managed-bean-name>
<managed-bean-class>brian.canadaShipping.CpstcHomeBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<description>handles initialization of pseudo-permanent data</description>
<managed-bean-name>cpstcApplicationBean</managed-bean-name>
<managed-bean-class>brian.canadaShipping.CpstcApplicationBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<description>- intializes HomeBean values which shouldn't be session scoped</description>
<managed-bean-name>cpstcRequestBean</managed-bean-name>
<managed-bean-class>brian.canadaShipping.CpstcRequestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
我在 ICEfaces 3.01 框架上运行,我相信它基于 JSF 2.2。我之前运行了一个请求范围的支持 bean,但我无法让这个新类工作。任何建议将不胜感激。提前致谢!