Reputation: 733
Got a really simple question on JSF 2 navigation mechanism:
I have two views, call it 'ProductEdit' and 'ProductList', with request scoped backing beans (I don't think this is relevant anyways). I have the following lines in the 'ProductEdit' view
<h:commandLink action="#{product.update('')}">
<h:outputText value="Update And Return"></h:outputText>
<f:param name="pageNo" value="#{productlist.pageNo}" />
</h:commandLink>
When a user clicks on the 'Update and Return' link in the 'ProductEdit' view, the specified action is performed(pretty standard in JSF) and outcome of it is the 'ProductList' view and the user is directed to the page no problem. However the URL of the page remains 'ProductEdit' in my browser although the view that is displayed is the 'ProductList' view.
Surely the URL must be updated, what am I doing wrong?
Hoping BalusC is online now!.
Upvotes: 3
Views: 3418
Reputation: 27496
Sorry for my previous answer, you can add "?faces-redirect=true"
at then end of your link returned by your action. Or, if you are going to use PrimeFaces, just set parameter ajax
to false
.
EDIT
public String update() {
return "index?faces-redirect=true";
}
I will borrow one of the BalusCs answers - here you can see few ways how to do it.
Upvotes: 4