Write a JSF page that lets the user enter loan amount, interest rate, and number
ID: 3677964 • Letter: W
Question
Write a JSF page that lets the user enter loan amount, interest rate, and number of years, as shown n Figure. Click the Compute Loan Payment button to compute and display the monthly and total loan payments, as shown in Figure. Use the Loan class given in Listing, Loan.java, to compute the monthly and total payments Cxerdse33 04-ozilla irefox Ele Edt Wew Hgtory Bookmarks Ioos Heb Exerise33 04 ÷ e ncahnst:80Richapter'ThrcfexerceeltarerFrerne33 04.xhtml ...-eRI. Gonge Compute Loan Payment Loan Amount Amnrual Intercst Ratc 5.0 Nunber of Years15 10000.0 Exerdse33 04 Result Mozilla Firefox He or view Hstory ookmarks 00S Hep ercke33 04,xhtmlC-Googe Loan Amount: 10000.0 Annual Interest Rate: 5.0 Number of Years: 15 Monthly Payment: 79.07936267415464 Monthly Payment: 14234.285281347835 The JSF page computes the loan payment Listing 1 public class Loan 2 private double annualInterestRate 3 private int numberOfYears 4 private double loanAmount; 5 private java.util.Date loanDate; 7/** Default constructor 8 public LoanO this(2.5, 1, 1000) 10 12 * Construct a loan with specified annual interest rate, 13 number of years, and loan amountExplanation / Answer
JSF provides containers that can be used to group components to achieve a desired layout. Three
containers are available under the Layout node in the Palette: GridPanel,GroupPanel,and LayoutPanel . GridPanel is like the Swing GridLayout . GroupPanel is similar to the Swing FlowLayout .LayoutPanel organizes child components using flow or absolute positioning.
public String ComputerLoan_action()
{
double loanAmount = Double.parseDouble(tfLoanAmount.getText().toString().trim());
int numberOfYears = Integer.parseInt(NUM_Year.getText().toString().trim());
double annualInterestRate = Double.parseDouble(Int_Rate.getText().toString().trim());
Total_Loan loan = new Total_Loan(annualInterestRate, numberOfYears, loanAmount);
gridPanel2.setRendered(true);
Month_Pay.setText(loan.getMonthlyPayment() + "");
Total_Pay.setText(loan.getTotalPayment() + "");
return null;
}
The handler obtains loanAmount , numberOfYears , and annualInterestRate from the input text fields. The program creates a Loan object. You need to create a Loan class for this method to work. To create the Loan class, choose File New Java Class to display the New Java Class dialog box.
Steps to create the UI:
1- Choose New › Visual Web JSF Page to display the New Page dialog box. Enter ComputeLoan in the File Name field. Click Finish to create ComputeLoan.jsp.
2- Drop a Button to the grid panel and Set the static text to Loan Amount, Number of Years, and Annual Interest Rate.
3- Drop a Text Field, a Static Text, and Set the static text to Monthly Payment and Total Payment.
4- Double-click the Compute Loan button in the Design pane to generate the method.
5- Then create Loan class.
6- Create database connection.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.