I have two pages, customer.xhtml and detailsCustomer.xhtml. Each one has its own Controller. I'm passing a parameter from customer to detailsCustomer.
The button in customer.xhtml:
<p:commandButton process="@this" update="@form" title="Button"
actionListener="#{customerController.showDetails(register)}"
icon="ui-icon-suitcase" />
The function in CustomerController:
public void showDetails(Customer c){
redirect("/customer/detailsCustomer.faces?customerId=" + c.getCustomerId());
}
In DetailsCustomerController
public DetailsCustomerController(){
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
strCustomer = ((HttpServletRequest) context.getRequest()).getParameter("customerId");
}
@PostConstruct
public void Init(){
registerCustomer = customerService.loadCustomer(Long.parseLong(strCustomer));
}
The first time works perfect, but if I close detailsCustomer (redirecting to customer) and select a new customer it keeps showing the last customer. Because the page is already built. I need that each time I press Button the page loads with the customer I selected, but when I debug I see that it's only going through the constructor and Init the first time I pressed Button.
Is it possible? Any idea on how to do it? I'll appreciate any help.