I'm writing a JSF web application, and I used to have the main backing bean request-scoped. I later changed it to session-scoped, and now I need to create a new request-scoped backing bean. I followed the format of my first request-scoped bean, but I can't seem to get the constructor to call at all. I've been using JSF for quite some time but I can't figure out why it won't call the constructor when I had a request-scoped class working just fine previously. :-S
Here is my backing bean class:
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!");
}
}
and here is my 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>
I'm running on the ICEfaces 3.01 framework, which I believe is based off of JSF 2.2. I had a request-scoped backing bean running before, but I can't get this new class to work. Any suggestions would be greatly appreciated. Thanks in advance!
For one, you don't have to call super() in your constructor, and for two, your annotations provide all that configuration so you don't need any of what you have in your faces-config.xml. That might even solve your problem : )
Also, are you referencing the request bean properly?