public Page createPage() {
for (MembershipTO memberTO : membershipsView.getList()) {
if (memberTO.getRoleId() == roleTO.getId()) {
return new MembershipModalPage(getPage().getPageReference(), membershipWin, memberTO,
templateMode);
}
}
membershipTO = new MembershipTO();
membershipTO.setRoleId(roleTO.getId());
membershipTO.setRoleName(roleTO.getName());
return new MembershipModalPage(getPage().getPageReference(), membershipWin, membershipTO,
templateMode);
}
});
membershipWin.show(target);
}
};
tree.setOutputMarkupId(true);
tree.getTreeState().expandAll();
add(tree);
membershipsView = new ListView<MembershipTO>("memberships", new PropertyModel<List<? extends MembershipTO>>(
userTO, "memberships")) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(final ListItem item) {
final MembershipTO membershipTO = (MembershipTO) item.getDefaultModelObject();
item.add(new Label("roleId", new Model(membershipTO.getRoleId())));
item.add(new Label("roleName", new Model(membershipTO.getRoleName())));
AjaxLink editLink = new ClearIndicatingAjaxLink("editLink", getPage().getPageReference()) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected void onClickInternal(final AjaxRequestTarget target) {
membershipWin.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new MembershipModalPage(getPage().getPageReference(), membershipWin,
membershipTO, templateMode);
}
});
membershipWin.show(target);