1

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.

thodorisbais
  • 2,314
  • 1
  • 20
  • 34
Ashkan
  • 310
  • 2
  • 15

1 Answers1

1

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:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • i know @ViewScoped working on current view and when view changed, the object lifecycle end. thanks for your help, i found this sample based on flashScope http://mkblog.exadel.com/2010/07/learning-jsf2-using-flash-scope/ – Ashkan Feb 15 '12 at 05:28
  • @BalusC: Any idea how to get questions like this 'accepted'? Duplicate them, you answering them again and then this one marking a s a 'duplicate'? Think it might make a difference with questions/answer getting more attention then? – Kukeltje Jan 22 '16 at 16:15
  • @Kukeltje: I think it will be more fit to just delete the answer and downvote the question. The question is after all badly formulated. Based on above (surprising) comment of OP referring to flash scope, OP's core problem appears to be like http://stackoverflow.com/q/25694423 (it could be closevoted as dupe of that). Perhaps OP misinterpreted meaning of "PRG". – BalusC Jan 22 '16 at 16:20
  • @BalusC: :-) I did not actually analyse the Q/A itself, but since you answered... I'm trying to get the 'unanswered' questions in JSF up. Deleting and downvoting does not really help, unless also flagging to close maybe – Kukeltje Jan 22 '16 at 16:24