Hi,

On Tue, Jan 15, 2013 at 9:30 AM, Dirk Forchel <dirk.forc...@exedio.com>wrote:

> Hallo,
> I'd like to get an hint how to provide the following URLs. What is the
> preferred way to improve our existing URLs?
> We need search-friendly URLs by naming them with clear keywords.
> For example for product pages the current URL looks like:
> http://localhost:8080/product.html?product=1234
> This should be changed to be:
> http://localhost:8080/products/category-name/product-name-1234.html
> where the "category-name" and "product-name" part are optional. Only the ID
> (e.g. 1234) is an essential parameter.
> I know, that the MountedMapper introduced with Wicket 1.5 is smart enough
> to
> handle a mix of supported parameter types
> (https://cwiki.apache.org/WICKET/request-mapping.html).
> And I assume, that mounting the "ProductPage" could be the following way:
>
> addPage("/products/${category_name}/${product_name}/#{id}",
> ProductPage.class)
>
> This uses a named parameter "id" and an optional named parameters
> "category_name" and "product_name".
>

It is the opposite - ${} is mandatory and #{} is optional.


>
> I assume that the following pattern is not working (I did not try it):
>
> addPage("/products/${category_name}/${product_name}-#{id}.html",
> ProductPage.class)
>

I haven't tried such patterns so I'm not sure that it works or not.
The following will work for sure:
mountPage("/products/${category}/${product}", ProductPage.class)

${product} will contain both the name and the id, probably the extension
too, but you can split it manually.



> How would I provide such a pattern?
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/MounterMapper-and-optional-parameters-tp4655372.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to