Reputation: 65
Is it possible to add panel inside of a Fragment (fragment is used on a page which inherited other page), so I was using tag also)?
Upvotes: 1
Views: 1864
Reputation: 6198
Yes, it is. Here's a simple example:
Page:
package com.mycompany;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.WebPage;
public class HomePage extends WebPage {
public HomePage(final PageParameters parameters) {
super(parameters);
Fragment fragment = new Fragment("fragment", "fragment-markup", this);
fragment.add(new MyPanel("panel"));
add(fragment);
}
}
Page markup:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<body>
<div wicket:id="fragment"/>
<wicket:fragment wicket:id="fragment-markup">
<div wicket:id="panel"/>
</wicket:fragment>
</body>
</html>
Panel:
package com.mycompany;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
public class MyPanel extends Panel {
public MyPanel(String id) {
super(id);
add(new Label("hello", Model.of("Hello")));
add(new Label("world", Model.of("World")));
}
}
Panel markup:
<!DOCTYPE html>
<html>
<body>
<wicket:panel>
<div wicket:id="hello"/>
<div wicket:id="world"/>
</wicket:panel>
</body>
</html>
Upvotes: 3