[solved] Handling extra long set of query parameters

Splash Forums PrettyFaces Users [solved] Handling extra long set of query parameters

This topic contains 6 replies, has 2 voices, and was last updated by  Lincoln Baxter III 11 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #17754



    We are interested in using prettyfaces to solve a problem we have with out website. Can someone give me an idea of where to begin?

    The basic problem is the application can take up to something like 20 query parameters, most of which are empty when the page is rendered. We would like to somehow get rid of all those empty parameters and only display in the URL the parameters that have a value.

    For example, take a URL like this


    And end up with this


    Can we do this with prettyfaces? Should we do this with prettyfaces?



    You most certainly can do this :) And it can also be done globally or per-URL-mapping if desired.

    You should take a look at the custom URL processor feature (which is new in the 3.0.x series.)


    You’d create a rewrite rule like this:

    <rewrite match="..." processor="gov.ssa.ond.url.processor.RemoveEmptyParams" redirect="301" />

    Your processor would look something like this:

    package gov.ssa.ond.url.processor;

    public class RemoveEmptyParams implements Processor {

    public String process(final RewriteRule rewrite, final String url) {
    return url.replaceAll("\w+=[&]?+", "");

    The pattern I’ve used in the replacement might not be exactly correct, but it will look something like that.


    The match="..." would need to be filled in with a pattern that matched URLs you wanted to be rewritten.


    For a more general idea of how to install prettyfaces, read the installation chapter of the reference guide (not yet published, but is available):




    Thank you Lincoln! I figured it wouldn’t be hard, just had no clue how to begin. I will give it a shot. I already got PrettyFaces installed. It was quite easy.




    Lincoln, the code you posted in my other other posting about the ClassCastException works just fine.

    FTR here it is

    public class RemoveEmptyParams implements Processor


    public String process(final RewriteRule rule, final String url)


    String result = url.replaceAll(“\?[^=]+=&”, “?”);

    result = result.replaceAll(“&[^=]+=&”, “&”);

    result = result.replaceAll(“&[^=]+=$”, “”);

    return result;



    I’m all set now. Thanks!


    Thank you TDR! :)

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

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

Comments are closed.