[solved] Resolving ambiguous patterns

Splash Forums PrettyFaces Users [solved] Resolving ambiguous patterns

This topic contains 5 replies, has 2 voices, and was last updated by  Lincoln Baxter III 7 years ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17734

    stuart
    Participant

    Hi,

    I’ve run into a slight problem with my URL structure. The following patterns are defined in my URL configuration:

    • /foo/search/by-name
    • /foo/#{fooBean.fooType}/#{fooBean.fooId}

    The second pattern is always matched for both these URLs. This means when a user visits /foo/search/by-name, the second pattern applies: fooBean.fooType is set to "search" and fooBean.fooId is set to "by-name".

    Is there some way of forcing the pattern matcher to distinguish between these URLs? The second pattern expects an integer as the last part of the URL. Can this be done with regular expressions or something (similar to Django)?

    Enjoying using the library. Thanks for the great work!

    Cheers,

    Stuart

    #19881

    I’m working on the discriminator functionality, but it’s not finished yet. Almost there… it will work something like this.

    /foo/#{/w+/ fooBean.fooType}/#{/d{2}/ fooBean.fooId}

    Straightforward enough? The regular expression provided between // will be substituted for the #{expression} when the pattern is matched against the URL.

    –Lincoln

    #19882

    Ok – you can get version 3.0.0, which is now in Maven Central:

    The syntax works like this:

    /foo/#{/w+/ foo:fooBean.fooType}/#{/d{2}/ bar:fooBean.fooId}

    becomes a regex that looks like:

    /foo/w+/d{2}

    Basically, path expressions may now contain regular expression parts that replace the default matching mechanism of [^/]+

    Here is the repository and artifact information.

    <dependency>
    <groupId>com.ocpsoft</groupId>
    <artifactId>prettyfaces-jsf2</artifactId>
    <version>3.0.0</version>
    </dependency>

    #19883

    Sorry, the artifactId and version scheme has changed. Here is the correct version info:

    <dependency>
    <groupId>com.ocpsoft</groupId>
    <artifactId>prettyfaces-jsf2</artifactId>
    <version>3.0.0</version>
    </dependency>

    #19884

    stuart
    Participant

    Thanks Lincoln – that looks pretty close to what I’m after.

    Will this be backported to the 1.2.x branch? I’m still on JSF 1.2.

    #19885

    <dependency>

    <groupId>com.ocpsoft</groupId>

    <artifactId>prettyfaces-jsf12</artifactId>

    <version>3.0.0</version>

    </dependency>

    :)

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

You must be logged in to reply to this topic.

Comments are closed.