Passing URL parameter using command button action

Splash Forums PrettyFaces Users Passing URL parameter using command button action

Tagged: 

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

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

    Muhammad Alaa
    Participant

    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 ?

    #22017

    Muhammad Alaa
    Participant

    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

    /pattern/1

    Thank you!

    #22018

    Glad you got it figured out :) Awesome!

    #22019

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

    #22020

    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.

    #22021

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

    #22022

    Muhammad Alaa
    Participant

    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 ??????

    #22023

    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”

    #22024

    Muhammad Alaa
    Participant

    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’.

    #22025

    Muhammad Alaa
    Participant

    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

    #22026

    I think you have to use this:

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

    Just remove the /faces part of the view identifier.

    #22027

    Muhammad Alaa
    Participant

    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 ?

    #22028

    Which PrettyFaces version are you using?

    #22029

    Muhammad Alaa
    Participant

    PrettyFaces version (3.3.2)- jsf 2

    #22030

    Ah, I forgot:

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

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

You must be logged in to reply to this topic.

Comments are closed.