On Wednesday 28 November 2007 14:00:30 Roy van Rijn wrote:
> And second, if you want to experiment with mounting you can also make
> your own coding strategy by implementing
> IRequestTargetUrlCodingStrategy. This is pretty straight-forward and,
> I imagine, fun to do :-)
I attempted to do something like that recently though it turned out to be a
bit more complicated. This strategy is intended to match any path found in
DB. Do you think it is a right way to go?
private static class MyIRequestTargetUrlCodingStrategy implements
IRequestTargetUrlCodingStrategy {
public String getMountPath() {
throw new UnsupportedOperationException();
}
public CharSequence encode(IRequestTarget requestTarget) {
throw new UnsupportedOperationException();
}
public boolean matches(IRequestTarget requestTarget) {
return false;
}
public IRequestTarget decode(RequestParameters requestParameters) {
final PageEntry entry = DB.findEntry(requestParameters.getPath());
final WebPage page = new MyPage(entry.data);
return new PageRequestTarget(page);
}
public boolean matches(String path) {
return DB.findEntry(path) != null;
}
}
private static class MyWebRequestCodingStrategy extends
WebRequestCodingStrategy {
/**
* Overriden because WicketFilter checks it for being null.
*/
public IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(String
path) {
if (DB.findEntry(path) != null) {
return new MyIRequestTargetUrlCodingStrategy();
}
return super.urlCodingStrategyForPath(path);
}
}
private static class MyWebRequestCycleProcessor extends
WebRequestCycleProcessor {
public IRequestCodingStrategy getRequestCodingStrategy() {
return new MyWebRequestCodingStrategy();
}
}
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new MyWebRequestCycleProcessor();
}
Dima
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]