On Tue, Jan 15, 2013 at 12:27 PM, Dirk Forchel <dirk.forc...@exedio.com>wrote:
> 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/>