Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<wicket:extend>
    ...
    <span wicket:id="myPanel">Example input (will be removed)</span>
    ...
    <wicket:fragment wicket:id="frag1">panel 1</wicket:fragment>
    <wicket:fragment wicket:id="frag2">panel 2</wicket:fragment>
</wicket:extend>

Fragments from other pages

It's possible to include fragments from other pages as well, even without using the <wicket:fragment>...</wicket:fragment> tags:

Warning

NB. This is not recommended usage: consider using Panels instead

Code Block
titleTest.html

<html>
<head>
	<title>Title</title>
</head>
<body>
	<span wicket:id="target">
		This will be replaced
	</span>
</body>
</html>
Code Block
titleTest.java

public class Test extends WebPage {

	public Test() {
		add(new Snippets().createTable("target"));
	}
}
Code Block
titleSnippets.html

<html>
<head>
	<title>Snippets</title>
</head>
<body>
	<span wicket:id="fragment.source">
		<table>
			<tr>
				<td>Hello</td>
				<td>World</td>
			</tr>
		</table>
	</span>
</body>
</html>
Code Block
titleSnippets.java

public class Snippets extends WebPage {

	private final WebMarkupContainer fragmentSource;

	public Snippets() {
		add(fragmentSource = new WebMarkupContainer("fragment.source"));
		setMarkupStream(getAssociatedMarkupStream(true));
	}

	public Component createTable(String id) {
		return new Fragment(id, fragmentSource.getId(), this);
	}
}

will be rendered as (ignoring some irrelevant JavaScript code in the header):

Code Block
titlerendered output

<html>
<head>
	<title>Title</title>
</head>
<body>
	<span>
		<table border="1">
			<tr>
				<td>Hello</td>
				<td>World</td>
			</tr>
		</table>
	</span>
</body>
</html>