Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1666

contribution: provide indexed urls for shared resources (with optional query string parameters)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.4-RC2
    • wicket
    • None

    Description

      I attached a patch for wicket-1.3.x and wicket.1.4.x to support indexed url encoding + query parameters for shared resources (somehow similar the way it is done with pages already). It contains javadoc and a WicketTestCase for regression tests.

      the main class is

      org.apache.wicket.request.target.coding.IndexedSharedResourceCodingStrategy

      and can be used in WebApplication like this:

      mount(new IndexedSharedResourceCodingStrategy(path, sharedResourceKey);

      here an example:

      for this url

      /mountpath/foo/bar/123?name=joe&languages=java&languages=scala

      the parameters value map will be

      key value
      ---------------------------------------------
      "0" "foo"
      "1" "bar"
      "2" "123"
      "name" "joe"
      "languages" String[]

      { "java", "scala" }

      accessing these is trivial:

      public class TestResource extends Resource
      {
      @Override
      public IResourceStream getResourceStream()

      { long value = getParameters().getAsLong("2"); String name = getParameters().getString("name"); String[] languages = getParameters().getStringArray("languages"); // create some custom resource stream based upon the parameters here }

      }

      so you can have urls like these

      /images/

      {imagename}

      .

      {format}

      /blog/2008/05/12/47-test-blog-entry.html

      with absolutely no effort.

      the greatest benefit is that shared resource urls look like static resources for the browser. this comes especially handy when utilizing browser caching. Also, the user will not realize the resources are served dynamically and bookmarking is easy. also, at least in my opinion, the urls are just "pretty"

      Attachments

        Activity

          People

            jdonnerstag Juegen Donnerstag
            pete Peter Ertl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: