Does that scale? This means an exception is thrown on each HTTP request
below /shop/
Regards,
Seb
On 14.11.2010 03:23, Igor Vaynberg wrote:
the easiest way is to mount a page onto /shop using indexed coding
strategy. parse the parameters, and throw a restartresponseexception
with the right page.
-igor
On Sat, Nov 13, 2010 at 5:15 PM, Sebastian<[email protected]> wrote:
Hi,
we are currently migrating a webapp to Wicket and have the requirement to
keep the existing URL structure.
Here is an example of REST-like URLs we need to match to different pages:
/shop/ => ShopWelcomePage.class
/shop/A/ => BrandsByFirstCharPage.class
/shop/A/Activision/ => BrandPage.class
/shop/A/Apple/ => BrandPage.class
/shop/A/Apple/iPhone-4G => ProductPage.class
/shop/H/HTC/ => BrandPage.class
/shop/<Category>/ => CategoryPage.class
/shop/<Category>/<SubCat> => SubCategoryPage.class
What is the best way to achieve this in Wicket 1.4/1.5?
I found https://issues.apache.org/jira/browse/WICKET-1534 where a
VersatileWebRequestCodingStrategy is proposed for Wicket 1.3. I updated the
code for Wicket 1.4 and it seems to work. However I am unsure if this really
is best practice or if there is a better solution available.
Here is an example how I am currently mounting pages using the
VersatileWebRequestCodingStrategy:
mount(new BookmarkablePageRequestTargetUrlCodingStrategy("/shop/",
ShopWelcomePage.class, null) {
public boolean matches(String path, boolean caseSensitive) {
return path.equals("shop/");
}
});
mount(new MixedParamUrlCodingStrategy("/shop/", BrandPage.class, new
String[]{"brandFirstChar", "brandName"}) {
Pattern pattern = Pattern.compile("^shop/([^/])/([^/]+)/$");
public boolean matches(String path, boolean caseSensitive) {
Matcher matcher = pattern.matcher(path);
return matcher.matches()&&
matcher.group(1).equals(matcher.group(2).substring(0, 1));
}
});
mount(new MixedParamUrlCodingStrategy("/shop/", ProductPage.class, new
String[]{"brandFirstChar", "brandName", "productSlug"}) {
Pattern pattern = Pattern.compile("^shop/[^/]/[^/]+/[^/]+/$");
public boolean matches(String path, boolean caseSensitive) {
return pattern.matcher(path).matches();
}
});
mount(new MixedParamUrlCodingStrategy("/shop/", CategoryPage.class, new
String[]{"category"}) {
Pattern pattern = Pattern.compile("^shop/[^/]{2,}/$");
public boolean matches(String path, boolean caseSensitive) {
return pattern.matcher(path).matches();
}
});
mount(new MixedParamUrlCodingStrategy("/shop/", SubCategoryPage.class, new
String[]{"category", "subCategory"}) {
Pattern pattern = Pattern.compile("^shop/[^/]{2,}/[^/]+/$");
public boolean matches(String path, boolean caseSensitive) {
return pattern.matcher(path).matches();
}
});
Thanks.
Regards,
Seb
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]