mount url coding strategies in webpage class
--------------------------------------------
Key: WICKET-2938
URL: https://issues.apache.org/jira/browse/WICKET-2938
Project: Wicket
Issue Type: Wish
Components: wicket
Reporter: Damian Nowak
Priority: Minor
Now, the appropriate place to mount url strategies is Application.init().
{noformat}
@Override
protected void init() {
mount(new MixedParamHybridUrlCodingStrategy("quote", Single.class, new
String[]{"id"}));
// mount another one
// and another..
}
{noformat}
But don't you think that Application.init() is not the right place for it?
{noformat}
public class Single extends WebPage {
static {
MyApplication.get().mount(new
MixedParamHybridUrlCodingStrategy("quote", Single.class, new String[]{"id"}));
}
public Single(PageParameters params) {
final int id = params.getAsInteger("id", 0);
// do my stuff here
}
}
{noformat}
It looks much better, doesn't it? URL strategy is an implementation detail of
the webpage class. Therefore, it should be mounted somewhere here. The code is
better maintainable. Suppose you do something with the webpage parameter names
- are you sure you look into Application.init()? I bet you will forget about
it. :)
My code almost works. If the webpage class hasn't been loaded by the
classloader yet, the application does not know anything about the URL strategy.
After the webpage class has been loaded, everything is OK then.
I know I can introduce a public static init(Application app) in my webpage
classes and execute it in my Application.init(). But it would be really nice if
I didn't have to.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.