After digging through links such as the following, I'm unable to solve the problem: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
I am getting the following error: javax.servlet.ServletException: /Project9.xhtml @13,55 value="#{ProjectBean.income}": Target Unreachable, identifier [ProjectBean] resolved to null
My form:
<!DOCTYPE html>
<html xmlns="http://wwww3.org/1999/xhtml"
xmlns:a="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<h:head>
<title>Project9</title>
</h:head>
<h:body>
<h:form>
Income: <h:inputText value="#{ProjectBean.income}"/>
Number of people: <h:inputText value="#{ProjectBean.numPeople}"/>
<h:commandButton value= "Submit" action= "Project9response"/>
</h:form>
</h:body>
</html>
I am not sure whether the right convention is wwww3.org or www.3.org but I have tried them both.
My Response page:
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<h:head>
<title><ui:insert name="title">Project 9 response</ui:insert></title>
</h:head>
<h:body>
Am I above the poverty level: #{ProjectBean.abovePovertyLevel()}
</h:body>
</html>
My Bean:
@ManagedBean
@SessionScoped
public class ProjectBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private double income;
private double numPeople;
//constructor is no arg
public ProjectBean() {
}
public double getIncome() {
return income;
}
public void setIncome(double income) {
this.income = income;
}
public double getNumPeople() {
return numPeople;
}
public void setNumPeople(double numPeople) {
this.numPeople = numPeople;
}
public boolean abovePovertyLevel() {
if ( income < (16460.00 + 4320.00) * (numPeople - 2)){
return false;
}
else {
return true;
}
}
}
My faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
version="2.3">
</faces-config>
I have my faces-config.xml and my javax-faces.2.2.8.jar file in the lib folder of WEB-INF I have my bean in the src folder of Java Resources
I have another project called helloworld with several little JSF projects that all work, and I have tried copying project9 into helloworld and running it, but I get the same error only on that project
I have tried cleaning my project as people have suggested
This is a student project and my first introduction to JSF and Tomcat. I'm using a Mac and Eclipse photon.
As I stated in a comment in my code, if I try to bypass the response xhtml file and go straight to the javabean method in my html form, I get an underline under ProjectBean.abovePovertyLevel() and the error "the action value does not match a navigation case outcome"
I'm not sure of some of the answers in the link above regarding CDI, etc, that all is above my head at this point.
Nevermind, I JUST solved this Added a name to my annotation as such: @ManagedBean(name="ProjectBean")
Also I realized that my method was wrong if I didn't declare poverty level first
This seemed to work