private static final List<String> list = Arrays.asList("a", "b", "c");
@SuppressWarnings("serial")
public DialogPage() {
final DialogWebMarkupContainer dialog = new DialogWebMarkupContainer(
"dialog", new DialogOptions().modal(true).resizable(false));
add(dialog);
add(new AjaxLink<Void>("dialog.open1") {
@Override
public void onClick(AjaxRequestTarget target) {
dialog.open(target);
}
});
DataView<String> listview = new DataView<String>("pageable",
new ListDataProvider<String>(list)) {
@Override
protected void populateItem(Item<String> item) {
this.add(item);
item.add(new Label("somecolumn", item.getModel()));
final Link<Void> link = new Link<Void>("accept") {
@Override
public void onClick() {
// do stuff
}
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
tag.put("href", "#");
}
};
item.add(link);
DialogWebMarkupContainer confirm = new DialogWebMarkupContainer(
"confirm-dialog",
new DialogOptions()
.modal(true)
.resizable(false)
.buttons(
new JQOptions()
.put("'Yes'",
$f("$(this).dialog('close'); window.location = '"
+ link.urlFor(ILinkListener.INTERFACE, null)
+ "';"))
.put("'No'",
$f("$(this).dialog('close')"))));
item.add(confirm);
link.add(JQBehaviors.mouseClick(confirm.open()));
}
};
add(listview);