Example usage for org.apache.wicket.markup.html.list ListView setVisibilityAllowed

List of usage examples for org.apache.wicket.markup.html.list ListView setVisibilityAllowed

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView setVisibilityAllowed.

Prototype

public final Component setVisibilityAllowed(boolean allowed) 

Source Link

Document

Sets whether or not this component is allowed to be visible.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.account.AccountOverViewPage.java

License:Apache License

public AccountOverViewPage() {

    setPageTitle(ResourceUtils.getModel("pageTitle.accountOverview"));

    add(new ButtonPageMenu("leftMenu", MyAccountPageLeftMenu.values()));

    Person user = personFacade.getPerson(EEGDataBaseSession.get().getLoggedUser().getUsername());

    if (user == null)
        throw new RestartResponseAtInterceptPageException(HomePage.class);

    // user information
    add(new Label("userName", new PropertyModel<String>(user, "email")));
    add(new Label("fullName", user.getGivenname() + " " + user.getSurname()));
    add(new Label("authority", new PropertyModel<String>(user, "authority")));

    add(new Label("phone", user.getPhone()));
    add(new Label("address",
            (user.getAddress() == null ? "" : user.getAddress() + ", ")
                    + (user.getZipCode() == null ? "" : user.getZipCode() + ", ")
                    + (user.getCity() == null ? "" : user.getCity())));
    //add(new Label("address", user.getAddress()));
    add(new Label("country", user.getCountry()));

    List<ResearchGroupAccountInfo> groupDataForAccountOverview = researchGroupFacade
            .getGroupDataForAccountOverview(user);
    boolean emptyGroups = groupDataForAccountOverview.isEmpty();

    WebMarkupContainer noGroups = new WebMarkupContainer("noGroups");
    noGroups.setVisibilityAllowed(emptyGroups);

    // list of user groups
    ListView<ResearchGroupAccountInfo> groups = new ListView<ResearchGroupAccountInfo>("groups",
            groupDataForAccountOverview) {

        private static final long serialVersionUID = 1L;

        @Override//  w w w .jav  a2s  . c  o  m
        protected void populateItem(ListItem<ResearchGroupAccountInfo> item) {
            ResearchGroupAccountInfo modelObject = item.getModelObject();
            item.add(new Label("title", modelObject.getTitle()));
            item.add(new Label("authority", modelObject.getAuthority()));
            item.add(new BookmarkablePageLink<ResearchGroupsDetailPage>("link", ResearchGroupsDetailPage.class,
                    PageParametersUtils.getDefaultPageParameters(modelObject.getGroupId())));
        }
    };
    groups.setVisibilityAllowed(!emptyGroups);

    BookmarkablePageLink<Void> editAccount = new BookmarkablePageLink<Void>("editLink", PersonFormPage.class,
            PageParametersUtils.getDefaultPageParameters(user.getPersonId()));

    add(groups, noGroups, editAccount);
}