You can also go more advanced, using any pattern supported by {@link MatchingResources}. For example, the first package example above is turned into "classpath*:/org/mycompany/wicket/pages/**/*.class".
For each class that is annotated, an appropriate {@link IRequestTargetUrlCodingStrategy}implementing class is created using the information in the {@link MountPath} annotationand any supplemental annotations. Each instance is added to the list to return. Each item in the returned list can then be mounted.
Typical usage is in your {@link Application#init()} method and utilizes the{@link AnnotatedMountList#mount} convenience method.
protected void init() { new AnnotatedMountScanner().scanPackage("org.mycompany.wicket.pages").mount(this); }
You could scan the entire classpath if you wanted by passing in null, but that might require more time to run than limiting it to known packages which have annotated classes.
Page classes annotation usage is as follows:
@MountPath(path = "hello") private class HelloPage extends Page { } @MountPath(path = "dogs", alt = {"canines", "k9s"}) @MountMixedParam(parameterNames = {"dexter", "zorro"}) private class DogsPage extends Page { }
The first example will mount HelloPage to /hello using the default encoding strategy (as returned by {@link #getDefaultStrategy} which is {@link BookmarkablePageRequestTargetUrlCodingStrategy}.
The second example will mount DogsPage at "/dogs" (as the primary) and as "/canines" and "/k9s" as alternates using the {@link MixedParamUrlCodingStrategy}. Further, the second example specifies that {"dexter", "zorro"} String array is to be passed to the constructor. The value for the pageMapName argument is null. @author Doug Donohoe
|
|
|
|
|
|
|
|
|
|