Query Parameters displayed in URL

Splash Forums PrettyFaces Users Query Parameters displayed in URL

This topic contains 6 replies, has 3 voices, and was last updated by  Lincoln Baxter III 10 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #17902



    I have just started using PrettyFaces and have been quite impressed with its capabilities.

    I am having a problems with using query parameters. I have put together a simple app to test PrettyFaces functionality with the goal of implementing SEO friendly URLs.

    The app passes category IDs as query parameters and I would like to be able to display the name of the category in the URL instead of the IDs as query parameters. (e.g. instead of store/category.xhtml?categoryID=2 show store/Rice).


    <h:link value=”Page2″ outcome=”page2″>

    <f:param name=”iid” value=”2″/>



    <h:outputText value=”passed id – #{page2Backing.iid}”/>




    public class Page2Backing {

    private Integer iid;

    public Integer getIid() {

    return iid;


    public void setIid(Integer iid) {

    this.iid = iid;




    <url-mapping id=”page2″>

    <pattern value=”/TheSecondPage/” />


    <query-param name=”iid”>#{page2Backing.iid}</query-param>


    When I use the above code, the iid property is populated with the id but the URL still displays the query param ?iid=2 after the rewritten /TheSecondPage/. How can I stop this from being displayed?

    Secondly for the goal described above, it is best to pass the name of the category name as an additional parameter to be displayed in the URL or can a look up be configured to retrieve the name from the passed ID?

    Thank you



    This sounds like a perfect example for path parameters and page actions:

    <url-mapping id="store">
    <pattern value="/store/#{storeBean.categoryName}" />

    An a bean like this one:

    public class Page2Backing {

    private String categoryName;

    private Category category;

    /* .... */

    public void onLoad() {
    this.category = categoryDao.findByName(categoryName);


    Please note that in this example you won’t have the ID to load the correct category but only the name. But this is required if you want SEO friendly URLs without IDs.

    Here a few references to the documentation:






    Thank you Christian, I will try the method you provided.

    I am still curious as to whether the ?iid=2 could be passed to the backing bean and suppressed from the URL in the example I provided.




    It can if you are willing to do two redirects in order to render a single page, and save the value into the session. Otherwise, no, not really.



    Basically that parameter needs to be *somewhere* in the URL on an HTTP GET request, otherwise it will never make it to the server. It could be in the path, it could be in a query-param, but it’s gotta be somewhere.



    Thank you Lincoln.

    Excellent job on Pretty Faces.



    Thank you :) Let us know if we can make it better!

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

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

Comments are closed.