Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6871447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:48:28+00:00 2026-05-27T03:48:28+00:00

Do I need to make a custom regex pattern to match URLs when I

  • 0

Do I need to make a custom regex pattern to match URLs when I have the following mapping (example):

<url-mapping id="approvedQuestions">
    <pattern>/questions/approved/#{viewOption}/</pattern>
    <view-id>/approved.xhtml</view-id>
</url-mapping>

where the viewoption-portion should also match when the user does NOT end the URL with ‘/’?
And is it possible to supply some kind of default value if the don’t add the viewOption portion at all?

And if I the viewOption is a enum, is it possible to lowercase the parameter? Now I have to write uppercase in to make it work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:48:29+00:00Added an answer on May 27, 2026 at 3:48 am

    You can use a custom regex to do this type of, but I recommend using a url-rewrite rule to append a trailing slash if one is missing. You should pick one URL (with or without the ‘/’ at the end) otherwise you are actually serving up the same resources with two distinct addresses, and you will be punished by search engines and other crawlers.

    To do this, I would use a rewrite rule such as the following:

    <rewrite match="/questions/approved/[^/]+" trailingSlash="append" />
    

    This will cause the server to detect when a ‘/’ is missing from the end of the URL, and it will redirect the request to the proper location, with a ‘/’ at the end.

    In order to address your enum issue, this is a bit more complicated. We don’t typically recommend binding values directly into enumerations. In this case, you are not actually binding into an enum (I’m guessing,) but are actually binding the literal string URL value into the request scoped EL context. This value is then being extracted somewhere else in your application, and that is where the conversion into an ENUM is taking place.

    Until PrettyFaces 4 comes out, I recommend instead binding the value into a String location, then using an action method to do the loading of the correct value yourself, like so:

    <url-mapping id="approvedQuestions">
        <pattern>/questions/approved/#{params.viewOption}/</pattern>
        <view-id>/approved.xhtml</view-id>
        <action>#{params.loadViewOption}</action>
    </url-mapping>
    

    If you want to try a more advanced URL-rewriting tool, also from OCPsoft, you can use “Rewrite” (http://ocpsoft.com/rewrite/), which is a Java-based URL-rewriting tool, but does not have as much integration with JSF.

    PrettyFaces 4 will be based on rewrite as a core, at which point, all of the features you currently use will also be available with the ability to do something more like this, which is what you want if I am not mistaken:

    .addRule(Join.path("/questions/approved/{viewOption}").to("/approved.xhtml")
    .where("viewOption")
    .matches("[^/]+/?")
    .transformedBy(TrailingSlash.append())
    .transformedBy(To.upperCase())
    

    You would need to create your own transformers because they haven’t been defined in the library yet, but that’s the general idea. It’s much more powerful than what’s currently possible with PrettyFaces, but does not provide the same JSF navigation integration, and is a little trickier to configure.

    I hope this helps,
    ~Lincoln

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am customizing wordpress blog and I have a need to make custom sidebar
I have homework that I need to make a custom string class using C
I have a client that needs a custom registration form. I need to make
I need to make custom text field which will format numeric values according to
What would i need to put in the SortIP function to make the custom
I have a crystal report file I need make a tiny edit in. It
I need to make an ArrayList of ArrayLists thread safe. I also cannot have
I need to make a custom download manager as I am using android 2.2
Somehow I need to make a custom file-open form. I manage to retrieve the
I need to make a custom list-style markers. Now it's done by adding element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.