Search code examples
prettyfaces

Ignore case in prettyfaces pattern


if you defined a url mapping as follows:

@URLMapping(id = "myPage", pattern = "/myPage", viewId = "/faces/pages/myPage.xhtml")

if you tried to enter the url as:

http:localhost:8080/myPage

this will work fine, but if you changed the case to:

http:localhost:8080/mypage

or http:localhost:8080/MYPAGE

it won't work, it won't find the page, so is there's a way to ignore the case in the pattern, or such thing is not supported in PrettyFaces yet, if not supported, then please suggest a workaround.


Solution

  • Something like this is currently not directly supported with PrettyFaces. But you could achieve something like this with a simple workaround:

    Change your mapping to a completely lowercase URL:

    @URLMapping(id = "myPage", pattern = "/mypage", viewId = "/faces/pages/myPage.xhtml")
    

    And then add a rewrite rule that performs the lowercase transformation:

    <rewrite match="(?i)/mypage" toCase="lowercase" redirect="chain" />
    

    I think this should work fine. You could also try to build a more general pattern so that you don't have to repeat the rewrite rule for every mapping.