Lab 6 replaces the CustomerController servlet with the ustomerDetails.xhtml JSF page.
Existing JSP pages need to be adapted to call the JSF page. Here's how you call a JSF page from a JSP or plain HTML page and pass a parameter to it.
- Change the AllCustomers.jsp page to call the JSF page.
- Existing call to the servlet
- New call to the JSF page
- Change the JSF backing bean to receive parameters and call code when it is created by a GET request.
- Receive a GET parameter in an attribute
- Call a method when the bean is created. The method looks up data using the value stored in the attribute in the previous step.
<a href="CustomerController?customerIdentity=<%= customers[i].getId()%>&submit=Get Customer">
<a href="CustomerDetails.xhtml?customerIdentity=<%= customers[i].getId()%>">
@ManagedBean(name="customerDetails") @RequestScoped public class CustomerManagedBean { @ManagedProperty("#{param.customerIdentity}") private String customerId = ""; ... }
@PostConstruct public void initCustomer() { if (customerId != null && customerId.length()!= 0){ retrieveCustomer(); } }
No comments:
Post a Comment