Currently, BasePage adds its markup to HomePage’s markup which is a subclass & that isn't a good practice. Just 1 file needs to be added, BasePage.html & it should include markup for the header panel. Then BasePage.java should be modified to add the header panel component to that.
I recommend that BasePage.html be implemented as follows:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="UTF-8">
<meta name="description" content="Put your description here!" />
<wicket:head>
<wicket:link>
<link rel="stylesheet" type="text/css" href="style.css"/>
</wicket:link>
</wicket:head>
</head>
<body>
<section class="container" wicket:id="headerpanel">
</section>
<section class="content_container">
<wicket:child/>
</section>
<footer>
<span>Put your footer here</span>
</footer>
</body>
</html>
and that BasePage.java be implemented as:
import org.apache.wicket.markup.html.WebPage;
public abstract class BasePage extends WebPage {
public BasePage() {
super();
add(new HeaderPanel("headerpanel"));
}
}
and that HomePage.html be implemented as:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="UTF-8">
<wicket:head>
<title>Title goes here!</title>
</wicket:head>
</head>
<body>
<wicket:extend>
<!-- Page specific markup goes here -->
</wicket:extend>
</body>
</html>
and that HomePage.java be implemented as:
package com.buzzwords.wicket;
import org.apache.wicket.markup.html.link.Link;
public class HomePage extends BasePage {
public HomePage() {
}
}
Now BasePage remains blissfully ignorant of HomePage and its markup hierarchy.
My example is using the new html5 doctype and character encoding specifications as well as some html5 tag candy.

0 comments:
Post a Comment