You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Easter <an...@gmail.com> on 2009/07/31 11:21:06 UTC

Custom URL mapping (wild cards)

Hi everyone,

I've got a interesting requirement and, being only a complete newbie to
Wicket, I'm not 100% sure I can achieve it. Basically, assume you have the
following URL to display a product:

app/products/1234

I know I can use bookmarkable links and URL mounting in Wicket to allow such
"pretty" URLs. However, something that is extremely common on the Web these
days is including additional path information in a URL that further
identifies the contents of the page - mainly for search engine
optimization/marketing reasons.

For example, the product with code 1234 might be the book "Wicket in
Action". So what I'd really want is for the following URL to work:

app/products/1234/Wicket-in-Action.html

Now, what you'll find in most cases is that the web application completely
ignores the URL after the product code so, even if I navigated to
app/products/1234/blah-blah-blah.html, it would still be the correct product
page for the Wicket in Action book.

So, my question is, does this requirement sound like something that would be
easily possible in Wicket (maybe with some custom URL mounting strategy)?

I can easily do something like this with the REST support in Spring MVC 3.0
because I can simply map a Spring MVC Controller to a URL using wildcarding.
With the annotation support in Spring MVC, I can do something like this:

@RequestMapping( value = "/products/{productId}/*", method =
RequestMethod.GET )
public ModelAndView getProduct( @PathVariable( value = "productId" ) String
productId) { ... }

What this example shows is that the0 method getProduct() will be invoked
with any URL that starts with /products/[productId]. So it doesn't matter if
the invoker has added additional path information, it will just be ignored.

I'd be keen to understand a bit more about URL mounting and whether I could
achieve something similar to this with Wicket. Maybe if there was some kind
of wildcarding strategy? It is also important that I can build bookmarkable
links in Wicket pages that could include the additional path information.

Thanks for any help you can give me,

Andrew

Re: Custom URL mapping (wild cards)

Posted by Igor Vaynberg <ig...@gmail.com>.
see org.apache.wicket.request.target.coding.IndexedParamUrlCodingStrategy,
its exactly what you want.

-igor

On Fri, Jul 31, 2009 at 2:21 AM, Andrew Easter<an...@gmail.com> wrote:
> Hi everyone,
>
> I've got a interesting requirement and, being only a complete newbie to
> Wicket, I'm not 100% sure I can achieve it. Basically, assume you have the
> following URL to display a product:
>
> app/products/1234
>
> I know I can use bookmarkable links and URL mounting in Wicket to allow such
> "pretty" URLs. However, something that is extremely common on the Web these
> days is including additional path information in a URL that further
> identifies the contents of the page - mainly for search engine
> optimization/marketing reasons.
>
> For example, the product with code 1234 might be the book "Wicket in
> Action". So what I'd really want is for the following URL to work:
>
> app/products/1234/Wicket-in-Action.html
>
> Now, what you'll find in most cases is that the web application completely
> ignores the URL after the product code so, even if I navigated to
> app/products/1234/blah-blah-blah.html, it would still be the correct product
> page for the Wicket in Action book.
>
> So, my question is, does this requirement sound like something that would be
> easily possible in Wicket (maybe with some custom URL mounting strategy)?
>
> I can easily do something like this with the REST support in Spring MVC 3.0
> because I can simply map a Spring MVC Controller to a URL using wildcarding.
> With the annotation support in Spring MVC, I can do something like this:
>
> @RequestMapping( value = "/products/{productId}/*", method =
> RequestMethod.GET )
> public ModelAndView getProduct( @PathVariable( value = "productId" ) String
> productId) { ... }
>
> What this example shows is that the0 method getProduct() will be invoked
> with any URL that starts with /products/[productId]. So it doesn't matter if
> the invoker has added additional path information, it will just be ignored.
>
> I'd be keen to understand a bit more about URL mounting and whether I could
> achieve something similar to this with Wicket. Maybe if there was some kind
> of wildcarding strategy? It is also important that I can build bookmarkable
> links in Wicket pages that could include the additional path information.
>
> Thanks for any help you can give me,
>
> Andrew
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org