public abstract class BasePage extends WebPage { // ... public BasePage(String title) { add(new Label("title", title)); } }
public class SubPage extends BasePage { public SubPage(PageParameters parameters) { super("whatever title"); } }If you need the page parameters in the BasePage constructor then feel free to pass them with the constructor too...
Regards, Sebastiaan Kaspar Fischer wrote:
I am using markup inheritance (<wicket:child> and <wicket:extend>) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass(SubPage.java). Has anybody found a better way? Here's my solution: <!-- BasePage.html --> <html> <head> <title wicket:id="title">[Page title]</title> </head> <body> <wicket:child/> </body> </html> <!-- SubPage.html --> <wicket:extend> <!-- anything ... --> </wicket:extend> public abstract class BasePage extends WebPage { // ... public BasePage(final PageParameters parameters) { add(new Label("title", new PropertyModel(this, "title"))); } public abstract String getTitle(); } public class SubPage extends BasePage { // ... public String getTitle() { return "whatever title"; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME Cryptographic Signature