Shopping Cart Application Create A Simple Shopping Cart App
Shopping Cart Application Create A Simple Shopping Cart Application
Create a simple shopping cart application that displays a list of books as an h:selectOneRadio element. When the user submits the form, store the user's selection in a @SessionScoped managed bean. Allow the user to return to the list of books and make additional selections. Provide a link to view the shopping cart. On the shopping cart page, display the list of selections the user made, the price of each book, and the total of all books in the cart. The list of books must be in radio buttons. The cart page should include a 30-minute countdown timer at the top, a total price displayed below, and a link to return to the previous page to add more books if desired.
Paper For Above instruction
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
// JavaScript function for the countdown timer
let countdownTime = 1800; // 30 minutes in seconds
let timerInterval;
function startTimer() {
timerInterval = setInterval(function() {
if (countdownTime
clearInterval(timerInterval);
alert("Your session has expired. Please update your cart if needed.");
// Optional: redirect to a session expired page
} else {
countdownTime--;
updateTimerDisplay();
}
}, 1000);
}
function updateTimerDisplay() {
const minutes = Math.floor(countdownTime / 60);
const seconds = countdownTime % 60;
document.getElementById("timer").textContent =
"Time remaining: " +
(minutes
(seconds
}
window.onload = function() {
startTimer();
updateTimerDisplay();
};