i want to know how can i do the same actions: adding object an redirect to list. here my jsp add page :
<?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"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<h:outputStylesheet library="css" name="table-style.css" />
</h:head>
<h:body>
<center>
<h2>Add New Customer</h2>
</center>
<h:form styleClass="add-fome">
<h:panelGrid columns="">
Name :
<h:inputText id="name" value="#{customer.name}" size="20"
required="true" label="Name">
</h:inputText>
<h:message for="name" style="color:red" />
Age :
<h:inputText id="age" value="#{customer.age}" size="20"
required="true" label="Age">
</h:inputText>
<h:message for="age" style="color:red" />
Address :
<h:inputTextarea id="address" value="#{customer.address}" cols="30"
rows="10" required="true" label="Address">
</h:inputTextarea>
<h:message for="address" style="color:red" />
</h:panelGrid>
<h:commandButton value="Submit" action="#{customer.addCustomer()}" />
<h:link value="Customer List" outcome="default" />
</h:form>
List page is named default.html In my bean here is the add methode that its working :
public String addCustomer() {
Customer cust = new Customer();
cust.setName(getName());
cust.setAddress(getAddress());
cust.setAge(getAge());
customerBo.addCustomer(cust);
clearForm();
return "";
}
For thes list method :
public List<Customer> getCustomerList() {
return customerBo.findAllCustomer();
}
so how can we make the redirection just before adding the customer? Thanks