URL Params from action method

Splash Forums PrettyFaces Users URL Params from action method

This topic contains 1 reply, has 2 voices, and was last updated by  Lincoln Baxter III 6 minutes ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27451

    predatorx64
    Participant

    Hello guys,

    i searched a lot, but i haven’t found a solution. How can i append URL parameters to the return of an action method?

    Given an action method like this:

    
    // Should redirect to /abc?param1=yes
    public String onCommandButton() {
       return "pretty:newDestination";
    // return "pretty:newDestination?param1=yes";
    }
    
    #27452

    Hi,

    To do this, you’ll need to create a “mapped query-parameter” in your pretty-config.xml file (or your class configuration if you are using annotations.)

    http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.queryparams

    <url-mapping id="store"> 
       <pattern value="/store/" /> 
       <view-id value="/faces/shop/store.jsf" />
       <query-param name="section"> #{bean.section} </query-param>
    </url-mapping>

    Then you just need to set the value of the bean before navigating to the page:

    public String onCommandButton() {
       bean.setSection("shoes");
       return "pretty:store";
    }

    PrettyFaces will extract the parameter value and use it when creating the URL.

    I hope this helps.

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

You must be logged in to reply to this topic.

Comments are closed.