Simple flow management in Post-Redirect-Get pattern
Asked Answered
M

1

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.

Morman answered 15/2, 2012 at 1:9 Comment(0)
Q
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:

Quickman answered 15/2, 2012 at 1:26 Comment(4)
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 mkblog.exadel.com/2010/07/learning-jsf2-using-flash-scopeMorman
@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?Bartley
@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 https://mcmap.net/q/17143/-pass-an-object-between-viewscoped-beans-without-using-get-params (it could be closevoted as dupe of that). Perhaps OP misinterpreted meaning of "PRG".Quickman
@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 maybeBartley

© 2022 - 2024 — McMap. All rights reserved.