THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Panel | ||||
---|---|---|---|---|
| ||||
|
Scope
ComponentBackground | componentJavadoc=Panel
Background
A Panel is a reusable component that holds markup and other components. If you want to reuse a component without copying it's markup into each page markup, extend the class Panel:
...
Panels can be used to create dynamic markup hierarchies.
FAQ
Examples
Typical usage
UsersPanel.java:
Code Block |
---|
{panel} public class UsersPanel extends Panel { public UsersPanel(String id, List users) { super(id); add(new ListView("users", users) { public void populateItem(final ListItem p_item) { final User user = (User) p_item.getModelObject(); p_item.add(new Label("username", user.getUsername())); p_item.add(new Label("password", user.getPassword())); }}); } } {panel} |
UsersPanel.html:
Code Block | ||||
---|---|---|---|---|
| ||||
{panel} <wicket:panel> <table> <tr wicket:id="users"> <td><span wicket:id="username"></span></td> <td><span wicket:id="password"></span></td> </tr> </table> </wicket:panel> {panel} |
That's for your reusable panel, which you can now use anywhere like:
Code Block |
---|
{panel} add(new UsersPanel("users", users); {panel} |
and:
Code Block |
---|
{panel} <span wicket:id="users">[users here]</span> {panel} |
or for previewability:
Code Block |
---|
{panel} <span wicket:id="users"> <wicket:remove> <table> <tr> <td>mini</td> <td>maxi</td> </tr> </table> <wicket:remove> </span> {panel} |
...