Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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
titelNavomaticApplication.java
borderStylesolid
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
titelPage1.java
borderStylesolid
package wicket.examples.navomatic;

import wicket.markup.html.WebPage;

public class Page1 extends WebPage
{
    public Page1()
    {
        add(new NavomaticBorder("navomaticBorder"));
    }
}

Page1.html

html
Code Block
html
titelPage1.htmlborderStylesolid
<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
titelPage2.java
borderStylesolid
public class Page2 extends WebPage
{
    public Page2()
    {
        add(new NavomaticBorder("navomaticBorder"));
    }
}

Page2.html

html
Code Block
titelborderStyle
html
Page2.htmlsolid
<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.

java
Code Block
java
titelNavomaticBorder.javaborderStylesolid
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
titelNavomaticBorder.html
borderStylesolid
<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>

...