Passing URL parameter using command button action

Splash Forums PrettyFaces Users Passing URL parameter using command button action


This topic contains 16 replies, has 3 voices, and was last updated by  Christian Kaltepoth 10 years ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
  • #18140

    Muhammad Alaa

    I am trying to pass url parameter from action method of command button

    <p:commandButton value=”add” action=”#{bean.add}” update=”msgs”/>

    public String addItem() {

    if (insert(value)) {

    return “pretty:AddDetails”;


    return null;


    where the AddDetails

    @URLMapping(id = “AddDetails”, pattern = “/AddDetails/#{itemId}”, viewId = “/faces/user-pages/item_details.xhtml”)

    I want to pass the itemId from the first page in method addItem()

    how can I do that ?


    Muhammad Alaa

    Is there a way to send a parameter for PrettyFaces navigation string?

    It would be something like this:

    return “pretty:some-url-mapping-id?1”

    Sending do


    Thank you!


    Glad you got it figured out :) Awesome!


    @lincoln: Does something like this really work? Even I didn’t know that! :)


    Apparently :p We should add some tests and documentation I guess, LOL! I seem to recall implementing this a while ago in a dream. Maybe it was real.


    I thought that setting path parameters only works for EL injected path parameters… And muhammadalaa’s post sounds more like a question, I think. ;)


    Muhammad Alaa

    It is a question I am still want to make the commandbutton do some action then redirect to a page with path parameter depending on the action results ??????


    Yes. You can do this now.

    Return the view id as normal. This works as long as you are using named path parameters.

    return “/faces/user-pages/item_details.xhtml?itemId=1”


    Muhammad Alaa

    I tried as you suggested

    return “/faces/user-pages/item_details.xhtml?itemId=1”

    but it did nothing at all when click the commandbutton

    but in the server log I noticed the following warning

    WARNING: JSF1015: Request path ‘/faces/user-pages/item_details.xhtml’ begins with one or more occurrences of the FacesServlet prefix path mapping ‘/faces’.


    Muhammad Alaa

    if it is working if there is some tutorial or working example that demonstrate url pass parameters in prettyfaces as using action method to handle command button action and redirect to page with parameters


    I think you have to use this:

    return "/user-pages/item_details.xhtml?itemId=1"

    Just remove the /faces part of the view identifier.


    Muhammad Alaa

    I tried to remove /faces part but nothing happened it does not even refresh but it calls the action method but with no navigation is there is a way to do what I asked for ?


    Which PrettyFaces version are you using?


    Muhammad Alaa

    PrettyFaces version (3.3.2)- jsf 2


    Ah, I forgot:

    return "/faces/user-pages/item_details.xhtml?itemId=1&faces-redirect=true";

Viewing 15 posts - 1 through 15 (of 17 total)

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

Comments are closed.