...
| 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 |
|---|
|
<html>
<head>
<title>Title</title>
</head>
<body>
<span wicket:id="target">
This will be replaced
</span>
</body>
</html>
|
| Code Block |
|---|
|
public class Test extends WebPage {
public Test() {
add(new Snippets().createTable("target"));
}
}
|
| Code Block |
|---|
|
<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 |
|---|
|
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 |
|---|
|
<html>
<head>
<title>Title</title>
</head>
<body>
<span>
<table border="1">
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</table>
</span>
</body>
</html>
|