Re: MounterMapper and optional parameters

2013-01-15 Thread Martin Grigorov
Hi,


On Tue, Jan 15, 2013 at 9:30 AM, Dirk Forchel dirk.forc...@exedio.comwrote:

 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/


Re: MounterMapper and optional parameters

2013-01-15 Thread Martin Grigorov
On Tue, Jan 15, 2013 at 12:27 PM, Dirk Forchel dirk.forc...@exedio.comwrote:

 Thanks Igor.


Actually my name is Ivan! :-)



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

 Yes, your are right.

  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.

 What is the right place to split it up manually. I guess, the ProductPage
 itself.
 What about the IPageParametersEncoder? What is this interface for?

 And another question. Assuming I would have two different pages. The first
 one shows a list of products (ProductListPage) and the second one is the
 product detail page (ProductPage) itself.
 I would like, the following mapping:

 http://localhost:8080/products/ - ProductListPage without any parameter
 shows all products.
 http://localhost:8080/products/category/ - ProductListPage with optional
 named parameter category shows products of a specific category.
 http://localhost:8080/products/category/product - ProductPage with
 mandatory named parameter product shows the specific product.

 This is quite a common mapping for a product-category-hierarchy.
 How would the correct mapping look like?

 mountPage(/products/#{category}/, ProductListPage.class)
 mountPage(/products/#{category}/${product}, ProductPage.class)

 To be honest, I'm a little bit confused about the same path segments.



The simplest solution is to use:

#mountPage(/products/#{category}/#{product}, ProductsEntryPage.class);

class ProductsEntryPage extends WebPage {

   public ProductsEntryPage(PageParameters params) {
 category = params.get(category)
 product = params.get(product)

 WebPage toRender;
 if (hasCategory(category)) {
   if (hasProduct(product)) {
 toRender = new ProductPage(category, product);
   }
   else {
 toRender = new CategoryPage(category);
   }
 }
 else {
toRender = new ProductListPage();
 }
 throw new RestartResponseException(toRender);
   }
}





 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/MounterMapper-and-optional-parameters-tp4655372p4655382.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/


Re: MounterMapper and optional parameters

2013-01-15 Thread Dirk Forchel
Sorry for the Igor, Martin.
Anyway, thank you for your help.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/MounterMapper-and-optional-parameters-tp4655372p4655384.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



MounterMapper and optional parameters

2013-01-14 Thread Dirk Forchel
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.

I assume that the following pattern is not working (I did not try it):

addPage(/products/${category_name}/${product_name}-#{id}.html,
ProductPage.class)

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