Search code examples
javajsfprettyfaces

How to redirect back to the same page using PrettyFaces?


I'd like to know how to redirect to the same page on action call.

I have this commandButton:

<h:commandButton action="#{someBean.edit}" value="Edit" />

This is the action:

@Named
@RequestScoped
public class SomeBean {

    public String edit() {
        // some logic
        return "theSamePage?faces-redirect=true";
    }

}

But it doesn't redirect to the same page, it just refreshes it so when I try to refresh the page by pressing F5 key, the duplicate submission occurs. This can be solved, under normal circumstances, with post/redirect/get. But faces won't send the redirect when the action method returns the same viewId as the viewId of the page that the request is send from.

I use prettyfaces.


Solution

  • return "pretty:"; 
    

    Is pretty much what you need.