1

I've been getting the same constant problem. Currently now I'm getting the error javax.el.PropertyNotFoundException: /index.xhtml @23,97 action="#{execise04.getInput}": Target Unreachable, identifier 'execise04' resolved to null

I'm not entirely sure what I'm doing wrong here is the code. I've looked at the other post that they say solved my issue and it doesn't solve my issue, and I don't understand a single thing its saying. Its not really giving a solution just turning me around in circles. Also I have had other issues such as once i press the button before I was getting a different error and it wouldn't open the second window that is supposed to display the output. Someone please help. I've been stuck on this for days and its getting incredibly frustrating.

<?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://java.sun.com/jsf/html">
    <h:head>
        <title>Exercise04</title>
    </h:head>
    <h:body>
        <h:form>
            <center>
                <h3>
                    Compute Loan Payment
                </h3>
                <h:panelGrid columns="2">
                    <h:outputLabel value="Loan Amount"/>
                    <h:inputText id="amount" value="#{exercise04.loanAmount}"/>
                    <h:outputLabel value="Annual Interest Rate"/>
                    <h:inputText id="rate" value="#{exercise04.annualInterestRate}"/>
                    <h:outputLabel value="Number Of Years"/>
                    <h:inputText id="years" value="#{exercise04.numberOfYears}"/>
                </h:panelGrid>
                <br />
                <h:commandButton value="Compute Loan Payment" action = "#{execise04.getInput}"/>
            </center>
        </h:form>
    </h:body>
</html>

<?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>Exercise02</title>
    </h:head>
    <h:body>
        <center>
            <h:outputText escape="false" value="{exercise02.table}" />
        </center>
    </h:body>
</html>



    import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "exercise04")
@SessionScoped
public class Exercise04 implements Serializable {
    private double annualInterestRate;
    private int numberOfYears;
    private double loanAmount;
    private java.util.Date loanDate;
public Exercise04() {
    this(10, 1, 1000);
}

public Exercise04(double annualInterestRate, int numberOfYears, double loanAmount) {
    this.annualInterestRate = annualInterestRate;
    this.numberOfYears = numberOfYears;
    this.loanAmount = loanAmount;
    loanDate = new java.util.Date();
}

public double getAnnualInterestRate() {
    return annualInterestRate;
}

public void setAnnualInterestRate(double annualInterestRate) {
    this.annualInterestRate = annualInterestRate;
}

public int getNumberOfYears() {
    return numberOfYears;
}

public void setNumberOfYears(int numberOfYears) {
    this.numberOfYears = numberOfYears;
}

public double getLoanAmount() {
    return loanAmount;
}

public void setLoanAmount(double loanAmount) {
    this.loanAmount = loanAmount;
}

public double getMonthlyPayment() {
    double monthlyInterestRate = annualInterestRate / 1200;
    double monthlyPayment = loanAmount * monthlyInterestRate / (1
            - (1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));
    return monthlyPayment;
}

public double getTotalPayment() {
    double totalPayment = getMonthlyPayment() * numberOfYears * 12;
    return totalPayment;
}

public java.util.Date getLoanDate() {
    return loanDate;
}

public String getInput() {
    return "<p style=\"color:red\"><br />"
    + "Loan Amount: " + loanAmount + "<br />"
    + "Annual Interest Rate: " + annualInterestRate + "<br />"
    + "Number Of Years: " + numberOfYears + "<br />"
    + "Monthly Payment: " + getMonthlyPayment() + "<br />"
    + "Total Payment: " + getTotalPayment() + "</p>";
}

}

  • Now i am having this error Unable to find matching navigation case with from-view-id '/index.xhtml' for action 'Exercise04_2' with outcome 'Exercise04_2' – Ashanti Negus Apr 27 '18 at 01:43
  • The "duplicate" isn't helping me solve the problem. I don't understand at all what it means. – Ashanti Negus Apr 27 '18 at 01:55

1 Answers1

0

You are mixing CDI with JSF annotations. @ManagedBean and @RequestScoped (with this package) are JSF annotations. @Named is a CDI annotation. If you want to use CDI remove @ManagedBean and change @RequestScoped package to javax.enterprise.context. If you don't want to use CDI (which I do not recommend because these annotations are deprecated) remove @Named annotation and add name attribute to @ManagedBean annotation.

Alex Fire
  • 707
  • 3
  • 7