Dynamic pattern dependant on path and view-param?

Splash Forums Rewrite Users Dynamic pattern dependant on path and view-param?

This topic contains 1 reply, has 2 voices, and was last updated by  Lincoln Baxter III 2 years, 12 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24636

    djmj
    Participant

    Is it possible and how to define dynamig patterns programatically if a certain path and view-param exists?

    Lets assume following folder structure.

    WEB-INF
    – sites
    — sitemap
    — about-us.xhtml
    — entity
    — sitemap
    —- about-us.xhtml
    — entity.xhtml
    index.xhtml

    The sitemaps exists both for the welcome page index.xhtml and also for the entity.xhtml site.

    So basically they follow a pattern:
    A pattern should be created that involves both cases since there are multiple subfolders (similar to sitemaps) with individual sites.

    // main
    addRule(Join.path("/about-us").to("/sites/sitemaps/about-us.xhtml"));
    // entity
    addRule(Join.path("/entity/{entity}/about-us").to("/sites/entity/sitemaps/about-us.xhtml"));

    Basically /entity/{entity} is optional and if its provided /entity should be an infix in the target.

    Extend:

    Entity view-param is converted and saved in a view-scoped bean and all links are created with that /entity infix like following example:

    <h:link outcome="/sites#{bean.entity eq null ? '/entity' : ''}/sitemaps/about-us.xhtml"
    	<o:param name="entity" value="#{bean.entity} converter="#{entityConverter} disabled="#{bean.entity eq null}/>
    </h:link>

    I don’t like this complete structure and would like to rewrite those urls automatically if this is possible. Furthermore I would love to automatically map all files in those directories without the extension?

    • This topic was modified 2 years, 12 months ago by  djmj.
    • This topic was modified 2 years, 12 months ago by  djmj.
    • This topic was modified 2 years, 12 months ago by  djmj.
    #24644
    addRule(Join.path("/entity/{x}").to("/sites/entity/{x}.xhtml"))
    .when(Not.any(ServletMapping.includes("/entity/{x}")))
    .where("x").matches(".*")

    If I understand correctly, you want one rule to handle all files. The only thing I can recommend is to create a wildcard pattern similar to (but perhaps more custom to your needs than) the above.

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

You must be logged in to reply to this topic.

Comments are closed.