...
Just as in the Hello World! example, we need to define our application. In this case, we set Page1
to be our home page.
Code Block |
---|
| java |
---|
| java |
---|
titel | NavomaticApplication.java |
---|
borderStyle | solid |
---|
|
package wicket.examples.navomatic;
import wicket.protocol.http.WebApplication;
public class NavomaticApplication extends WebApplication
{
public NavomaticApplication()
{
}
public Class getHomePage()
{
return Page1.class;
}
}
|
...
Code Block |
---|
| java |
---|
| java |
---|
titel | Page1.java |
---|
borderStyle | solid |
---|
|
package wicket.examples.navomatic;
import wicket.markup.html.WebPage;
public class Page1 extends WebPage
{
public Page1()
{
add(new NavomaticBorder("navomaticBorder"));
}
}
|
Page1.html
Code Block |
html |
---|
| html |
---|
| titel | Page1.html | borderStyle | solid |
---|
|
<html>
<body>
<span wicket:id = "navomaticBorder">
You are viewing Page1
</span>
</body>
</html>
|
...
The Page2 Java and HTML files look almost identical (and we'll omit the sources for Page3 altogether because it follows the same pattern):
Code Block |
---|
| java |
---|
| java |
---|
titel | Page2.java |
---|
borderStyle | solid |
---|
|
public class Page2 extends WebPage
{
public Page2()
{
add(new NavomaticBorder("navomaticBorder"));
}
}
|
Page2.html
Code Block |
html |
---|
| html | titel |
---|
| Page2.html | borderStyle | solid |
---|
|
<html>
<body>
<span wicket:id = "navomaticBorder">
You are viewing Page2
</span>
</body>
</html>
|
...
So how does NavomaticBorder
work? Glad you asked. The Java code below simply adds the two BoxBorder
components you see. These components are nested borders which each draw a thin black line around their contents. The rest of the magic is in the NavomaticBorder
markup.
Code Block |
java |
---|
| java |
---|
| titel | NavomaticBorder.java | borderStyle | solid |
---|
|
package wicket.examples.navomatic;
import wicket.markup.html.border.Border;
import wicket.markup.html.border.BoxBorder;
public class NavomaticBorder extends Border
{
public NavomaticBorder(final String componentName)
{
super(componentName);
add(new BoxBorder("navigationBorder"));
add(new BoxBorder("bodyBorder"));
}
}
|
NavomaticBorder.html
Code Block |
---|
| html |
---|
| html |
---|
titel | NavomaticBorder.html |
---|
borderStyle | solid |
---|
|
<html>
<body>
<wicket:border>
<p>
<table>
<tr>
<td>
<span wicket:id = "navigationBorder">
<b>Navigation Links</b>
<p>
<wicket:link>
<a href = "Page1.html">Page1</a><br/>
<a href = "Page2.html">Page2</a><br/>
<a href = "Page3.html">Page3</a>
</wicket:link>
</p>
</span>
</td>
<td>
<span wicket:id = "bodyBorder">
<wicket:body/>
</span>
</td>
</tr>
</table>
</p>
</wicket:border>
</body>
</html>
|
...