Hi,
We are in the process of moving our applications from JSP to Wicket.
Right now we're writing a framework with BasePages and base components to
build on and are
learning Wicket "on the fly".
The BasePage contains a HeaderPanel which renders the "Headline" of the
page:
<!-- BasePage.java -->
public BasePage() {
super();
.
.
header = new HeaderPanel("header", getHeaderImagePath());
add(header);
}
We then subclass BasePage and implement getHeaderImagePath() which is
abstract.
HeaderPanel reads the header from a .properties file and uses a different
resourceKey
depending on what "mode" the page is in. E.g. if the page is in "edit
mode", the HeaderPanel
tries to read editHeadline, and if the page is in "view mode" the
HeaderPanel tries to read
viewHeadline:
<!-- Extract from HeaderPanel.java constructor -->
add(new Label("viewHeadline",
new StringResourceModel("viewHeadline",
this, model)) {
@Override
public boolean isVisible() {
return getMode() == Mode.VIEW;
}
}.setRenderBodyOnly(true));
<!-- SubclassPage.java -->
public class SubclassPage extends BasePage
public SubclassPage() {
super();
}
}
Now for the "problem":
We would like to be able to read the localization properties from the Page
_Subclass_ .properties file.
This apparently won't work because the HeaderPanel is added in BasePage,
and uses
that as "parent component" to HeaderPanel in the StringResourceModel.
Of course we can create methods like getViewHeadline() and force the Page
subclass to
implement/override them, but is there a better way?
Is it possible to get the values from the Page Subclass .properties file?
Thanks!
Regards,
Leo
---
Leo Erlandsson, M. Sc.