You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Navomatic

The Navomatic application shows the use of border components and links to create a navigation component that can easily be dropped into any web page.

In all the Wicket examples, you have to put all files in the same package directory. This means putting the markup files and the java files next to one another. It is possible to alter this behavior, but that is beyond the scope of this example. The only exception is the obligatory web.xml file which should reside in the WEB-INF/ directory of your web application root folder.

The link in the navigation to the current page is automatically turned into italic text to indicate to the user what page they are on. The first screen capture shows the Page1 page with the Page1 link in italics.

When you click on the Page2 link, you get the following screen.

As you can see, Page1 has no special style anymore, and Page2 is now displayed in italics. Also the message box shows that we are viewing Page2 instead of Page1.

Navigation component

To create a reusable navigation component we are going to use a wicket.markup.html.border.Border component. From the Border Javadoc:

A border component has associated markup which is drawn and determines placement of any markup and/or components nested within the border component.

The portion of the border's associated markup file which is to be used in rendering the border is denoted by a <wicket:border> tag. The children of the border component instance are then inserted into this markup, replacing the first <wicket:body/> tag in the border's associated markup.

For example, here is markup for a simple Border subclass, a usage of that border, and the markup which would be output on rendering:

Border markup

Border usage

Rendered markup

<html>
<body>
  <wicket:border>
      First <wicket:body/> Last
  </wicket:border>
</body>
</html>
<html>
<body>
  <span wicket:id = "myBorder">
      Middle
  </span>
</body>
</html>
<html>
<body>
      First Middle Last
</body>
</html>
  • No labels