1
votes

I'm looking for a best practice for navigating from one page to another based on Post-Redirect-Get pattern in JSF 2.0 I previously worked with Spring Webflow and it's an amazing framework, but I'm looking for a simple way.

I also tried the @ViewScoped annotation, but it's not working in PRG. In addition, t:saveState works perfectly in JSF 1.2, but doesn't work in JSF 2.0

I would be glad if you gave me any advice.

1

1 Answers

1
votes

If it's pure page-to-page navigation, rather use plain GET links instead of POST forms. JSF2 offers you the new <h:link> tag for this which can take a navigation case as outcome.

So, e.g.

<h:link value="Next page" outcome="next" />

(which goes to next.xhtml in the same folder)

instead of

<h:form>
    <h:commandLink value="Next page" action="next?faces-redirect=true" />
</h:form>

That's also instantly much friendlier for searchbots.

See also: