Map part of URL to Parameter

Splash Forums Rewrite Users Map part of URL to Parameter


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

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #23814


    Using Rewirte how do I make URLs like this:
    out of:

    I have already set view params.

    • This topic was modified 8 years, 7 months ago by  zozan. Reason: added the library I wanted to do the job with, i.e. rewrite and not prettyfaces

    You can use a Join for this. Just add the following rule to your configuration provider:



    Thanks Christian. It made the URL nice but destroyed my styles. It seems the page doesn’t read my styles anymore. What’s wrong?



    Thanks again. I solved it by adding .withInboundCorrection())



    Oops.It didn’t.



    In addition to this, when I add rule .addRule(Join.path("/{Home}").to("/{Home}.xhtml")
    the link <h:commandLink id="viewProduct" action="#{productController.viewProduct()}">
    <h:outputText value="#{item.title}"/>
    <f:setPropertyActionListener target="#{}" value="#{}"/>
    does not work. It just reloads the page.


    You have to make sure that your patterns don’t match other resources. Generally it is a good idea to restrict the regex of the parameters as you did it. In case of your product page it would be a good idea to restrict the parameter to numbers:


    If you have problems with broken graphics or styles, please post the exact URL and all your rules.

    For the home page it seems like you actually don’t use a parameter. Just use a string literal:


    And I think you don’t need the .when(DispatchType.isRequest()) part.



    I solved the styles problem by adding #{request.contextPath} to the links. And for The commandLink by `.addRule()
    .perform(Redirect.temporary(context.getContextPath() + “/products#”))` Thanks, your point to add a check for id is a good idea and that I don’t need to set the DispatchType.isRequest(). I’m quite realizing the work of rewrite. Thanks again.


    Yep! You have to manually add the context path to the Request πŸ™‚ We can’t assume that because maybe you want to redirect to another application! Glad you got it working.

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

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

Comments are closed.