...
Panel | ||||
---|---|---|---|---|
| ||||
|
Definition
Wicket provides quite a few ways to modularize your web page creation. In addition to Markup Inheritance, you should also have a look at how you can simplify page creation using Wicket tags and Fragments. Markup Inheritance lets a Component extend the markup of it's its super class. The subclass markup is inserted at one point in the super class markup.
Let's see an example:
Parent.java:
Panelcode |
---|
public class Parent extends Component {} |
Parent.html:
Panelcode |
---|
... parent content ... <wicket:child/> ... parent content ... |
Child.html
Panelcode |
---|
<wicket:extend> ... child content ... </wicket:extend> |
Child.java:
Panelcode |
---|
public class Child extends Parent {} |
Renders as:
Panelcode |
---|
... parent content ... ... child content ... ... parent content ... |
It is just like having a Panel defined in your Component class markup, and let subclasses add the Panel. But it doesn't need an extra Component and is much easier to use. Markup Inheritance is also a convenient replacement for most Border components.
...
Code Block |
---|
class Parent extends WebpageWebPage { public Parent() { } } |
Next define a child Page. First the markup:
...
- <head> will be inserted in output automatically if required
- <head> is not a wicket specific tag and you must use add() for components within in <head>
- <head> is supported by panels, borders and inherited markup, but is not copied to the output. They are for previewability only (except on Pages)
- <wicket:head> is not necessary in Page markup. Wicket interprets <head> as <wicket:head> automatically.
- <wicket:head> makes sense in Panels, Borders and inherited markup (of Panels, Borders and Pages)
- components within <wicket:head> must be added by means of add() like allways with Wicket. No difference (anymore)
- <wicket:head> and it's content is copied into the output. Component contained in <wicket.head> are rendered as usual
Using Markup Inheritance with Panels
Markup Inheritance works with panels as well as Pages. To make this work, you have to make the markup container a transparent resolver, or add the child components to the markup container.
To mark an container as transparent resolver, override
Code Block | ||||
---|---|---|---|---|
| ||||
WebMarkupContainer wmc = new WebMarkupContainer( "wmc" ) {
@Override
public boolean isTransparentResolver()
{
return true;
}
};
|