[solved] How do I use the outcome parameter with Rewrite? (Ans: use annotations)

Splash Forums Rewrite Users [solved] How do I use the outcome parameter with Rewrite? (Ans: use annotations)


This topic contains 13 replies, has 4 voices, and was last updated by  Christian Kaltepoth 7 years, 11 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
  • #25872


    I was trying to do this:

    <p:button value="Register" outcome="/register" />

    But that gives me an NPE, like here http://stackoverflow.com/questions/17503177/pbutton-outcome-throws-npe-while-houtputlink-value-works where Lincoln pointed out that this was wrong, and a couple of ways to get around it if you’re using PrettyFaces.

    The relevant section of my HttpConfigurationProvider is a simple
    (I discovered the annotation method after authoring the HttpConfigurationProvider).

    I’m using Rewrite, not PrettyFaces. I’m new to JSF and haven’t used PrettyFaces, so I’m jumping into this purely from a Rewrite perspective. I’ve fetched the documentation from the GitHub repo because the documentation on this site keeps failing for me, but that’s another issue.

    I’m using tomcat 7.0.50, javax.faces-2.2.4, javax.servlet.jsp.jstl-api-1.2.2, primefaces-4.0, rewrite-servlet-2.0.10.Final, and rewrite-integration-faces-2.0.10.final.

    • This topic was modified 7 years, 11 months ago by  austinian.
    • This topic was modified 7 years, 11 months ago by  austinian.

    You have to use the plain JSF view for the outcome like this:

    <p:button value="Register" outcome="/Register.xhtml" />

    And to get nice redirects, you should do this:

    <p:button value="Register" outcome="/Register.xhtml?faces-redirect=true" />




    Hope following code will helpful .

    public Navigate getTestView() {
    return Navigate.to(“Register.xhtml”);

    <p:button value=”Register” outcome=”bean.testView” />




    Right, I know how to do that, I guess I didn’t state my question well. I’m trying to get the button to send the user to “/register”, you know, a nicer looking URL. Since I’m not using prettyfaces, I’m not sure how to get the URL to look like that when the outcome is “/Register.xhtml”


    The second code I posted in my first reply should result in a clean URL. Clicking the button will result in a postback to the server followed by a redirect to the clean URL.



    I tried using the second code you wrote, but the URL in the browser after I click the button is http://localhost:8080/Register.xhtml;jsessionid=C5DDFB24FCDFEA5F7DDADC0844566AAA
    I guess the section in the documentation I’m looking for is the yet-to-be-published-or-created “Response Interception”?

    • This reply was modified 7 years, 11 months ago by  austinian.
    • This reply was modified 7 years, 11 months ago by  austinian.

    Could you please post your complete configuration. The web.xml, the configuration provider, the pom.xml and so on?



    Sorry, I thought I had already included a link to Github. The navigation branch is the one that I’m working out how to use Rewrite on:


    Not sure why exactly, but try using /Web/Register.xhtml instead of just Register.xhtml in your Navigate result.


    Your rules look simple enough, I see no reason why this shouldn’t be working.


    Could you also try this:

    <h:link outcome="/Register.xhtml">Register</h:link>

    Just to make sure that this problem isn’t caused by the PrimeFaces button.



    <h:link value="Register" outcome="/NewVolunteer.xhtml" />
    Resulting URL:

    <h:link value="Register" outcome="/NewVolunteer.xhtml?faces-redirect=true" />
    Resulting URL:

    I’m going to try to use annotations and see if I get different results.

    • This reply was modified 7 years, 11 months ago by  austinian.


    Alright, I’m not sure why, but this is what ended up working:

    I added this annotation to RegistrationBean.java
    @Join(path="/register", to="/Web/NewVolunteer.xhtml")

    commented out this line in the HttpConfigurationProvider

    and used this line in the facelet
    <p:button value="Register" outcome="/NewVolunteer.xhtml" />

    and now the URL shows up as expected. I’m going to just use annotations everywhere now, as it’s both how I’m used to working with this stuff, and it seems to be the way that’s working best. Thanks for your help with troubleshooting, not sure how useful this is as a test case for you, since I’m unsure as to whether this is expected behavior.


    Perhaps your configuration provider wasn’t picket up correctly? However, I’m glad to hear you got it working.

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

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

Comments are closed.