How to redirect with parameter ?

Splash Forums PrettyFaces Users How to redirect with parameter ?

This topic contains 4 replies, has 3 voices, and was last updated by  msaleh 9 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #18302


    hi, i have mapping like this:

    @URLMapping(id = "edituser", pattern = "/edituser/#{ id: userBean.userId}", viewId = "/faces/pages/users/editUser.xhtml")

    and i want to redirect to it from an action method, so i tried the following:

    return "pretty:edituser/" + userObj.getId();

    but it didn’t work, please advise, thanks.


    When you return “pretty:edituser”, make sure that you have set the value of #{userBean.userId} to the value you want to use in the URL. PrettyFaces will extract the value from this location (based on what you have configured in your pattern,) and build the URL accordingly.

    In summary:

    return "pretty:edituser"

    But I actually like the syntax that you suggested – perhaps we should consider this for the future.

    @christian? thoughts?


    Another option would be to return something like this:

    return "/faces/pages/users/editUser.xhtml?faces-redirect=true&id="+userObj.getId();

    @lincoln: This should work, right? I think you mentioned this on the forums some time ago.

    Actually I think we could perhaps create some builder-like approach to simplify the task of creating the correct outcome. What about something like this:

    return OutcomeBuilder.mapping("edituser").with("id", userObj.getId()).toOutcome();


    return OutcomeBuilder.mapping("edituser").param(userObj.getId()).toOutcome();


    return OutcomeBuilder.viewId("/faces/pages/users/editUser.xhtml").with("id", userObj.getId()).toOutcome();

    What do you think?



    @lincoln Baxter III, your solution sometimes doesn’t work in case of i am redirecting from two different view beans.

    think of a case when i am in UserBean and i want to redirect with Parameter to AgencyBean

    both beans are view scope.



    @lincoln Baxter III, oh thanks your solution worked even with beans with different views.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.