PrettyFaces: outbound rewriting broken on Rewrite

Splash Forums PrettyFaces Users PrettyFaces: outbound rewriting broken on Rewrite

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

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
  • #24715



    to get around some bugs ( agin) i’m know trying to use outbound URL rewriting from Prettyfaces which works with prettyfaces-3.3.3 but not with rewrite-2.0.5.

    // Action from bean
    public String go() {
      return "/faces/Page.xhtml?id=2&path=page&faces-redirect=true";
    <!-- pretty-config --><url-mapping id="start">
            <pattern value="/#{ /[a-zA-Z0-9]{3}[a-zA-Z0-9]*/ path : someBean.path}" >
                <validate index="0" validator="#{someBean.validate}" />
            <view-id value="/faces/Home.xhtml" />
        <url-mapping id="next" parentId="start">
            <pattern value="/page"/>
            <view-id value="/faces/Page.xhtml" />

    Home.xhtml has this:
    <h:commandButton action="#{someBean.go}" value="Button"/>

    Result URL with prettyfaces-3.3.3:

    Result URL with rewrite 2.0.5:

    I guess you guys know that there are other issues with prettyfaces-3.3.3, so i really don’t want to go back.

    So any ideas?


    • This topic was modified 8 years, 4 months ago by  hendrik.

    Could you show me the rewrite dependencies in your POM file?





    And prettyfaces:


    Looks right to me, it matches the documentation.


    First thing to try is to remove this:


    It is not required if you are using the rewrite dependencies you’ve included.



    I know, it’s commented out. Only one of the two is in the POM. If i go with the prettyfaces 3.3.3 dependenciy it’s working, with the rewrite + prettyfaces compat module it’s not.

    Edit: typos…

    • This reply was modified 8 years, 4 months ago by  hendrik.


    Have a look at my test project. I’m on Glassfish 3.1.2, JavaEE 6, Servlet 3.

    EDIT: http://localhost:8080/PrettyFacesTest/home, klick the button and check URL. Rewriting should work with prettyfaces but not with rewrite + compat module.

    • This reply was modified 8 years, 4 months ago by  hendrik.
    • This reply was modified 8 years, 4 months ago by  hendrik.

    Hey Hendrik,

    I just want to send you a quick “thank you” for uploading the example app. This will hopefully help to identify the problem. Unfortunately both Lincoln and I are very busy currently. So it may take some time to have a deeper look at your app.



    I just played a bit with your app. I think you are right. Something is not working correctly with the PrettyFaces compatibility module. I’m not sure what is causing this. But it seems to be caused by the path parameter in your mapping. If I remove the parameter and replace it with a constant string, everything works fine… Really weird…


    I tried to reproduce these issues with some tests.

    Here is the pretty-config.xml:

    I’m using some h:link components to test the outbound rewriting:

    And here are the tests:

    It seems like the outbound rewriting isn’t working at all as soon as there is a parameter added to the h:link. Even if I add a parameter that doesn’t correspond to a path parameter. Very weird. I wonder why other tests doesn’t fail. Perhaps our test coverage isn’t as good as we thought in this area.


    Good news. I think I just fixed this issue.

    The problem was that was used for URLs even if there wasn’t a query string at all which lead to invalid parameters in the resulting QueryString object. I don’t want to bore you with the details, but I think it should work now.

    Could you perhaps give the latest build of 2.0.6-SNAPSHOT a try? Some infos on how to use the snapshots can be found here:




    i was moving last week, now back at work.

    The link to does not work for me, looks like the content could not be loaded.

    I guess i have to add the sonatype-snapshots repository, but i can’t find any 2.0.6-SNAPSHOT. Or do i have to get the snapshot from github in some way?


    Yes, the snapshots are available in the sonatype repository:;gav~org.ocpsoft.rewrite~rewrite-servlet~~~

    You should be able to get 2.0.6-SNAPSHOT if you add this repository declaration to your pom:



    Thanks for the help Christian. It’s working now for my test application, i will also try the snapshot with my actual application today. That might take some time.


    Awesome! Thanks for letting me know. I hope we will be able to release 2.0.6.Final soon.



    Looks like there is still a problem. I can’t really figure out why:

    On one page i have a viewParam like these:

    <ui:define name="metadata">
                <o:viewParam name="id"
                             required="true" />
                <f:event type="preRenderView"
                         listener="#{someBean.preRenderView}" />

    But in my preRenderView someId is null. “id” is totally unmapped in the pretty-config, should therefore be appended as query-param (&id=whatever) and be injected into someBean.someId. Is this expected behaviour? Should the value be null?
    I’m actually trying to avoid the query-param tag because of problems like the one mentioned in

    There are also 2 parentIds (in a hierarchy) in the pretty-config for the URL in question, i don’t know if this might be related.

    It works if i define a query-param mapping for, set this value and invoke the navigationhandler:

    // anotherBean
    public void onRowSelect(SelectEvent selectEvent) {
            this.navigationHandler.handleNavigation(this.facesContext, null, pretty:someBeansId);
    <url-mapping id="someBeansId" parentId="parentId">
            <pattern value="/some" />
            <view-id value="/fs/private/parent/Some.xhtml" />
            <query-param name="id">#{}</query-param>

    But then i get problems with AJAX + ViewScope etc(see, so i actually want to navigate with a link like “/fs/private/parent/Some.xhtml?id=1234&mappedParam=whatever” which is supposed to be rewritten to /whatever/some?id=1234.

    PrettyFacesTest project works fine now, but it lacks the viewParam and navigationHandler. Should be easy to add and test though.

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

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

Comments are closed.