use of org.apache.wicket.markup.html.list.ListItem in project wicket by apache.
the class ComponentQueueingTest method repeater1.
@Test
public void repeater1() {
TestPage p = new TestPage();
p.setPageMarkup("<p wicket:id='lv'><p wicket:id='b'><p wicket:id='c'></p></p></p>");
LV l = new LV(3) {
@Override
protected void populateItem(ListItem<Integer> item) {
item.queue(new B(), new C());
}
};
p.queue(l);
tester.startPage(p);
assertThat(l.size(), is(3));
for (Component item : l) {
assertThat(p, hasPath(new Path(l, item, new B(), new C())));
}
}
use of org.apache.wicket.markup.html.list.ListItem in project wicket by apache.
the class ComponentQueueingTest method repeater3.
/**
* repeater with a panel inside
*/
@Test
public void repeater3() {
TestPage p = new TestPage();
p.setPageMarkup("<p wicket:id='a'><p wicket:id='lv'><p wicket:id='b'><p wicket:id='q'></p></p></p></p>");
MarkupContainer a = new A();
LV l = new LV(3) {
@Override
protected void populateItem(ListItem<Integer> item) {
TestPanel q = new TestPanel("q");
q.setPanelMarkup("<wicket:panel><p wicket:id='r'><p wicket:id='s'></p></p></wicket:panel>");
q.queue(new R(), new S());
item.queue(q, new B());
}
};
p.queue(a, l);
tester.startPage(p);
assertThat(l.size(), is(3));
for (Component item : l) {
assertThat(p, hasPath(new Path(a, l, item, new B()).add("q").add(new R(), new S())));
}
}
use of org.apache.wicket.markup.html.list.ListItem in project oc-explorer by devgateway.
the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.
/**
* pending files section
*/
private void addPendingFilesComponent() {
pendingFiles = new WebMarkupContainer("pendingFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
if (filesModel != null && filesModel.size() > 0) {
for (FileMetadata file : filesModel) {
if (file.isNew()) {
setVisibilityAllowed(true);
return;
}
}
}
setVisibilityAllowed(false);
}
};
pendingFiles.setOutputMarkupPlaceholderTag(true);
pendingFiles.setOutputMarkupId(true);
add(pendingFiles);
pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// upload)
for (FileMetadata file : filesModel) {
if (file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
item.add(new Label("fileTitle", item.getModelObject().getName()));
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(pendingFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
}
};
pendingFiles.add(list);
}
use of org.apache.wicket.markup.html.list.ListItem in project the-app by devops-dojo.
the class OrderItemListPanel method orderItemList.
private Component orderItemList() {
return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) {
private int orderItemCounter = 1;
@Override
protected void populateItem(ListItem<OrderItemInfo> orderItem) {
orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++)));
orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name")));
orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description")));
orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum"))));
}
@Override
protected void onDetach() {
orderItemCounter = 1;
super.onDetach();
}
};
}
use of org.apache.wicket.markup.html.list.ListItem in project the-app by devops-dojo.
the class NavigationPanel method navigationEntryView.
private ListView<NavigationEntry> navigationEntryView(final String id, final IModel<List<NavigationEntry>> listModel) {
return new ListView<NavigationEntry>(id, listModel) {
private static final long serialVersionUID = -2695266767809997711L;
@Override
protected void populateItem(ListItem<NavigationEntry> listItem) {
WebMarkupContainer item = new WebMarkupContainer("item");
NavigationEntry navigationEntry = listItem.getModelObject();
WebMarkupContainer pageLink = navigationLink(navigationEntry);
pageLink.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
final String template = "%sLink";
@Override
public String getObject() {
return String.format(template, navigationEntry.getName().toLowerCase());
}
}, " "));
pageLink.add(new Label("name", Model.of(navigationEntry.getName())));
if (navigationEntry.getPageClass().isAnnotationPresent(ModalPanelItem.class)) {
pageLink.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 8111739824971748968L;
@Override
protected void onEvent(AjaxRequestTarget target) {
target.appendJavaScript(loginModalPanel.generateToggleScript());
}
});
pageLink.add(new AttributeModifier("href", "#"));
}
item.add(pageLink);
item.setVisibilityAllowed(navigationEntry.isVisible());
item.add(new AttributeModifier("class", activeModel(navigationEntry)));
listItem.add(item);
}
private IModel<String> activeModel(NavigationEntry navigationEntry) {
Class<? extends Page> currentPageClazz = getPage().getPageClass();
Class<? extends Page> navigationPageClazz = navigationEntry.getPageClass();
boolean assignableFrom = navigationPageClazz.isAssignableFrom(currentPageClazz);
if (!assignableFrom)
return Model.of("");
if (!currentPageClazz.isAnnotationPresent(EnumProductTypeNavigationItem.class))
return Model.of("active");
PageParameters currentParameters = getPage().getPageParameters();
PageParameters navigationParameters = navigationEntry.getPageParameters();
if (currentParameters == null || currentParameters.isEmpty()) {
String enumName = navigationParameters.get("type").toString();
EnumProductTypeNavigationItem enumNavigationItem = currentPageClazz.getAnnotation(EnumProductTypeNavigationItem.class);
return Model.of(StringUtils.equals(enumNavigationItem.defaultEnum(), enumName) ? "active" : "");
}
return Model.of(currentParameters.equals(navigationParameters) ? "active" : "");
}
};
}
Aggregations