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

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

Introduction

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

Prototype

public ListView(final String id, final List<T> list) 

Source Link

Usage

From source file:fiftyfive.wicket.css.IterationCssBehaviorTestPage.java

License:Apache License

public IterationCssBehaviorTestPage() {
    List<String> list = Arrays.asList("1", "2", "3", "4", "5", "6");
    ListView<String> listView = new ListView<String>("listView", list) {
        @Override//  w ww  .  j av  a2  s.c  o m
        protected void populateItem(ListItem<String> it) {
            it.add(new IterationCssBehavior("odd", "even", "first", "last", "iteration"));
        }
    };
    listView.setViewSize(5);
    add(listView);

    DataView<String> dataView = new DataView<String>("dataView", new ListDataProvider<String>(list)) {
        @Override
        protected void populateItem(Item<String> it) {
            it.add(new IterationCssBehavior("odd", "even", "first", "last", "iteration"));
        }
    };
    dataView.setItemsPerPage(5);
    add(dataView);

    add(newLoop("loop0", 0));
    add(newLoop("loop1", 1));
    add(newLoop("loop2", 2));
}

From source file:fr.openwide.maven.artifact.notifier.web.application.project.component.ItemAdditionalInformationPanel.java

public ItemAdditionalInformationPanel(String id, IModel<? extends ItemAdditionalInformation> model) {
    super(id, model);

    // Website link
    add(new HideableExternalLink("websiteLink",
            BindingModel.of(model, Binding.itemAdditionalInformation().websiteUrl().url())));

    // Issue tracker link
    add(new HideableExternalLink("issueTrackerLink",
            BindingModel.of(model, Binding.itemAdditionalInformation().issueTrackerUrl().url())));

    // Scm link//from  w  ww  . java 2  s  . c o m
    add(new HideableExternalLink("scmLink",
            BindingModel.of(model, Binding.itemAdditionalInformation().scmUrl().url())));

    // Changelog link
    add(new HideableExternalLink("changelogLink",
            BindingModel.of(model, Binding.itemAdditionalInformation().changelogUrl().url())));

    // Licenses
    final IModel<List<ProjectLicense>> licensesModel = BindingModel.of(model,
            Binding.itemAdditionalInformation().licenses());
    add(new CountLabel("licensesHeader", "project.description.links.licenses",
            new LoadableDetachableModel<Number>() {
                private static final long serialVersionUID = 1L;

                @Override
                protected Number load() {
                    List<ProjectLicense> licenses = licensesModel.getObject();
                    if (licenses != null) {
                        return licenses.size();
                    }
                    return 0;
                }
            }));
    add(new ListView<ProjectLicense>("licenses", licensesModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ProjectLicense> item) {
            item.add(new CoreLabel("licenseShortLabel",
                    BindingModel.of(item.getModel(), Binding.projectLicense().shortLabel())).hideIfEmpty());

            item.add(new Label("licenseLabel",
                    BindingModel.of(item.getModel(), Binding.projectLicense().label())));

            item.add(new HideableExternalLink("licenseLink",
                    BindingModel.of(item.getModel(), Binding.projectLicense().licenseUrl())));
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            List<ProjectLicense> licenses = licensesModel.getObject();
            setVisible(licenses != null && !licenses.isEmpty());
        }
    });
}

From source file:fr.xebia.demo.wicket.blog.view.admin.category.ListCategoryPage.java

License:Apache License

private void createComponents(List<Category> categories) {
    PageLink pageLink = new PageLink("addLink", AddCategoryPage.class);
    add(pageLink);//from w  ww. jav  a2s .c o  m
    add(new SearchCategoryForm("categoryForm"));
    if (categories == null) {
        categories = getCategories();
    }
    add(new ListView("categories", categories) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final ListItem listItem) {
            final Category category = (Category) listItem.getModelObject();
            Link editLink = new Link("viewLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        Category viewedCategory = getCategory(category);
                        if (viewedCategory == null) {
                            throw new RestartResponseException(ListCategoryPage.class,
                                    PageParametersUtils.fromStringMessage(
                                            getString("category.list.notFound", new Model(category))));
                        }
                        PageParameters pageParameters = new PageParameters();
                        pageParameters.put(ViewCategoryPage.PARAM_CATEGORY_KEY, viewedCategory);
                        setResponsePage(ViewCategoryPage.class, pageParameters);
                    } catch (Exception e) {
                        logger.error("Error while getting category", e);
                        throw new RestartResponseException(ListCategoryPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            };
            editLink.add(new Label("id", String.valueOf(category.getId())));
            listItem.add(editLink);
            listItem.add(new Link("deleteLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        deleteCategory(category);
                        setResponsePage(ListCategoryPage.class, PageParametersUtils
                                .fromStringMessage(getString("category.list.deleted", new Model(category))));
                    } catch (Exception e) {
                        logger.error("Error while deleting category", e);
                        throw new RestartResponseException(ListCategoryPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            });
            listItem.add(new Label("description", new Model(category.getDescription())));
            listItem.add(new Label("name", category.getName()));
            listItem.add(new Label("nicename", category.getNicename()));
        }
    });
    add(new Label("resultCount", new StringResourceModel("category.list.resultCount", this, null,
            new Object[] { categories.size() })));
}

From source file:fr.xebia.demo.wicket.blog.view.admin.comment.ListCommentPage.java

License:Apache License

private void createComponents(List<Comment> comments) {
    add(new SearchCommentForm("commentForm"));
    if (comments == null) {
        comments = getComments();//from   w ww  .j av  a2  s  .c o m
    }
    add(new ListView("comments", comments) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final ListItem listItem) {
            final Comment comment = (Comment) listItem.getModelObject();
            Link viewLink = new Link("viewLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        Comment viewedComment = getComment(comment);
                        if (viewedComment == null) {
                            throw new RestartResponseException(ListCommentPage.class,
                                    PageParametersUtils.fromStringErrorMessage(
                                            getString("comment.list.notFound", new Model(comment.getId()))));
                        }
                        PageParameters pageParameters = new PageParameters();
                        pageParameters.put(ViewCommentPage.PARAM_COMMENT_KEY, viewedComment);
                        setResponsePage(ViewCommentPage.class, pageParameters);
                    } catch (Exception e) {
                        logger.error("Error while getting comment", e);
                        throw new RestartResponseException(ListCommentPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            };
            viewLink.add(new Label("id", new Model(comment.getId())));
            listItem.add(viewLink);
            listItem.add(new Link("deleteLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        deleteComment(comment);
                        setResponsePage(ListCommentPage.class, PageParametersUtils
                                .fromStringMessage(getString("comment.list.deleted", new Model(comment))));
                    } catch (Exception e) {
                        logger.error("Error while deleting comment", e);
                        throw new RestartResponseException(ListCommentPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            });
            listItem.add(new Label("approved", new Model(comment.getApproved())));
            listItem.add(new Label("author", comment.getAuthor()));
            listItem.add(new Label("email", comment.getEmail()));
            listItem.add(new Label("date", new Model(comment.getDate())));
            listItem.add(new Label("postId", new Model(comment.getPostId())));
        }
    });
    add(new Label("resultCount",
            new StringResourceModel("comment.list.resultCount", this, null, new Object[] { comments.size() })));
}

From source file:fr.xebia.demo.wicket.blog.view.admin.post.ListPostPage.java

License:Apache License

private void createComponents(List<Post> posts) {
    PageLink pageLink = new PageLink("addLink", AddPostPage.class);
    add(pageLink);/*  ww  w .j  a va2 s . co  m*/
    add(new SearchPostForm("postForm"));
    if (posts == null) {
        posts = getPosts();
    }
    add(new ListView("posts", posts) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final ListItem listItem) {
            final Post post = (Post) listItem.getModelObject();
            Link viewLink = new Link("viewLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        Post viewedPost = getPost(post);
                        if (viewedPost == null) {
                            throw new RestartResponseException(ListPostPage.class,
                                    PageParametersUtils.fromStringErrorMessage(
                                            getString("post.list.notFound", new Model(post.getId()))));
                        }
                        PageParameters pageParameters = new PageParameters();
                        pageParameters.put(ViewPostPage.PARAM_POST_KEY, viewedPost);
                        setResponsePage(ViewPostPage.class, pageParameters);
                    } catch (Exception e) {
                        logger.error("Error while getting post", e);
                        throw new RestartResponseException(ListPostPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            };
            viewLink.add(new Label("id", String.valueOf(post.getId())));
            listItem.add(viewLink);
            listItem.add(new Link("deleteLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    try {
                        deletePost(post);
                        setResponsePage(ListPostPage.class, PageParametersUtils
                                .fromStringMessage(getString("post.list.deleted", new Model(post))));
                    } catch (Exception e) {
                        logger.error("Error while deleting post", e);
                        throw new RestartResponseException(ListPostPage.class,
                                PageParametersUtils.fromException(e));
                    }
                }
            });
            listItem.add(new Label("date", new Model(post.getDate())));
            listItem.add(new Label("modified", new Model(post.getModified())));
            listItem.add(new Label("author", post.getAuthor()));
            listItem.add(new Label("status", post.getStatus()));
            listItem.add(new Label("title", post.getTitle()));
            String categoryName = null;
            if (post.getCategory() == null) {
                categoryName = "";
            } else {
                categoryName = post.getCategory().getNicename();
            }
            listItem.add(new Label("category", categoryName));
        }
    });
    add(new Label("resultCount",
            new StringResourceModel("post.list.resultCount", this, null, new Object[] { posts.size() })));
}

From source file:fr.xebia.demo.wicket.blog.view.HomePage.java

License:Apache License

private void createComponents() {
    add(new ListView("posts", getLastPosts()) {
        private static final long serialVersionUID = 1L;

        @Override//from  w w  w  . ja v  a2  s. com
        public void populateItem(final ListItem postListItem) {
            final Post post = (Post) postListItem.getModelObject();
            postListItem.add(new Label("modified", post.getModified().toString()));
            postListItem.add(new Label("author", post.getAuthor()));
            postListItem.add(new Label("title", post.getTitle()));
            postListItem.add(new Label("content", post.getContent()));
            IModel categoryNicename;
            if (post.getCategory() != null) {
                categoryNicename = new Model(post.getCategory().getNicename());
            } else {
                categoryNicename = new StringResourceModel("nocategory", this, null);
            }
            postListItem.add(new Label("category", categoryNicename));
            postListItem.add(new Link("addCommentLink") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    PageParameters pageParameters = new PageParameters();
                    pageParameters.put(AddCommentPage.PARAM_POSTID_KEY, post.getId());
                    setResponsePage(AddCommentPage.class, pageParameters);
                }
            }.setVisible(post.getCommentsAllowed()));
            ListView commentsListView = new ListView("comments", getCommentsForPostId(post.getId())) {
                private static final long serialVersionUID = 1L;

                @Override
                public void populateItem(final ListItem commentListItem) {
                    final Comment comment = (Comment) commentListItem.getModelObject();
                    commentListItem.add(new Label("author", comment.getAuthor()));
                    commentListItem.add(new Label("date", comment.getDate().toString()));
                    commentListItem.add(new Label("content", comment.getContent()));
                }
            };
            postListItem.add(commentsListView);
        }
    });
}

From source file:gr.abiss.calipso.wicket.AggregatesReportPanel.java

License:Open Source License

public void addComponents(final ItemSearch itemSearch) {
    final List<ColumnHeading> columnHeadings = itemSearch.getColumnHeadingsToRender();
    List<ColumnHeading> groupByHeadings = itemSearch.getGroupByHeadings();
    final Map<String, List> results = getCalipso().findItemGroupByTotals(itemSearch);
    logger.info("Results: " + results);
    @SuppressWarnings("unchecked")
    ListView headings = new ListView("headings", groupByHeadings) {
        @SuppressWarnings("unchecked")
        protected void populateItem(ListItem listItem) {
            final ColumnHeading ch = (ColumnHeading) listItem.getModelObject();

            String label = ch.isField() ? localize(ch.getLabel()) : localize("item_list." + ch.getNameText());
            listItem.add(new Label("heading", label));

            final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt");
            listItem.add(new ListView("itemList", results.get(ch.getNameText())) {
                private static final long serialVersionUID = 1L;

                protected void populateItem(ListItem listItem) {
                    Object[] result = (Object[]) listItem.getModelObject();
                    String labelKey = localize("CustomAttributeLookupValue." + result[0] + ".name");

                    listItem.add(new Label("column", labelKey + ": " + result[1]));
                }//from w ww.  j a va 2s .  co  m
            });
        }
    };
    add(headings);

}

From source file:gr.abiss.calipso.wicket.ApplicationsDashboardPanel.java

License:Open Source License

/**
 * /*  ww  w  . j  a  va2  s.  c o  m*/
 * @param id
 * @param breadCrumbModel
 * @param isSingleSpace
 */
@SuppressWarnings({ "unchecked", "serial" })
public ApplicationsDashboardPanel(String id, IBreadCrumbModel breadCrumbModel) {
    super(id, breadCrumbModel);

    final User user = getPrincipal();
    // current space???
    List<UserSpaceRole> nonGlobalSpaceRoles = new ArrayList<UserSpaceRole>(user.getSpaceRolesNoGlobal());
    logger.info("nonGlobalSpaceRoles: " + nonGlobalSpaceRoles);
    WebMarkupContainer message = new WebMarkupContainer("message");
    setCurrentSpace(null);
    TreeSet<UserSpaceRole> sortedBySpaceCode = new TreeSet<UserSpaceRole>(new UserSpaceRoleComparator());
    sortedBySpaceCode.addAll(nonGlobalSpaceRoles);
    List<UserSpaceRole> sortedBySpaceCodeList = new ArrayList<UserSpaceRole>(sortedBySpaceCode.size());
    sortedBySpaceCodeList.addAll(sortedBySpaceCode);

    // first add the existing user items
    List<Object[]> userItems = getCalipso().selectLatestItemPerSpace(this.getPrincipal());
    final Set<String> usedSpacePrefixes = new HashSet<String>();
    // add the spaces not used by the user
    final WebMarkupContainer noItems = new WebMarkupContainer("noItems");
    add(new ListView<Object[]>("items", userItems) {
        @Override
        protected void populateItem(final ListItem listItem) {
            Object[] o = (Object[]) listItem.getModelObject();
            Date closingDate = (Date) o[2];
            listItem.add(new Label("spaceName",
                    localize(new StringBuffer("Space.").append(o[1]).append(".name").toString())));
            listItem.add(new Label("closingDate", DateUtils.format(closingDate)));
            Integer closed = new Integer(99);
            listItem.add(new Label("status", o[4].toString().equals("99") ? "complete" : "incomplete"));
            //getSpace().getPrefixCode() + "-" + getId() + "-" + [3];
            String uniqueRefId = new StringBuffer(o[0].toString()).append("-").append(o[5]).append("-")
                    .append(o[3]).toString();
            Link refIdLink = new BookmarkablePageLink("uniqueRefId", ItemViewPage.class,
                    new PageParameters("0=" + uniqueRefId));
            refIdLink.add(new Label("uniqueRefId", o[4].toString().equals("99") ? "view" : "edit"));

            listItem.add(refIdLink);
            if (closingDate != null && closingDate.after(new Date())) {
                // refIdLink.setVisible(false);
            }

            usedSpacePrefixes.add(o[0].toString());
            noItems.setVisible(false);
        }
    });
    add(noItems);

    // add the spaces not used by the user
    final WebMarkupContainer noSpaces = new WebMarkupContainer("noSpaces");
    noSpaces.setVisible(true);
    add(new ListView<UserSpaceRole>("spaces", sortedBySpaceCodeList) {
        @Override
        protected void populateItem(final ListItem listItem) {
            UserSpaceRole userSpaceRole = (UserSpaceRole) listItem.getModelObject();
            Space space = userSpaceRole.getSpaceRole().getSpace();
            listItem.add(new Label("spaceTitle", localize(space.getNameTranslationResourceKey())));
            listItem.add(new Label("spaceDescription", space.getDescription()));
            String closingDate = "";
            if (space.getClosingDate() != null) {
                closingDate = localize("closingDate") + ": " + DateUtils.format(space.getClosingDate());
            }
            listItem.add(new Label("closingDate", closingDate));
            Link prefixLink = new BookmarkablePageLink("prefixLink", NewItemPage.class,
                    new PageParameters("spaceCode=" + space.getPrefixCode()));
            listItem.add(prefixLink.add(new Label("prefixLinkLabel", "Apply")));
            boolean active = true;
            if (space.getClosingDate() != null) {
                active = space.getClosingDate().after(new Date());
            }
            if (!active || usedSpacePrefixes.contains(space.getPrefixCode())) {
                listItem.setVisible(false);
            } else {
                noSpaces.setVisible(false);
            }
        }
    });
    add(noSpaces);
}

From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributeFormPanel.java

License:Open Source License

private void addName(final CompoundPropertyModel model, final boolean isMandatory) {
    logger.debug("addName, isMandatory: " + isMandatory);
    if (model.getObject() instanceof AssetTypeCustomAttribute) {
        List<Language> languages = getCalipso().getSupportedLanguages();
        CustomAttribute attr = (CustomAttribute) model.getObject();
        if (MapUtils.isEmpty(attr.getNameTranslations())) {
            attr.setNameTranslations(getCalipso().getNameTranslations(attr));
            logger.info("Loaded '" + attr.getName() + "' name translations from the DB: "
                    + attr.getNameTranslations());
        } else {//from   w  w  w  .j  a v a 2  s.  c  om

            logger.info("Loaded '" + attr.getName() + "' name translations from memory: "
                    + attr.getNameTranslations());
        }
        // TODO: change this to only use the space-supported languages after
        // moving asset type creation to space admin
        //nameTranslations
        add(new ListView("nameTranslations", languages) {
            @Override
            protected void populateItem(ListItem listItem) {
                Language language = (Language) listItem.getModelObject();
                TextField description = new TextField("name");
                if (isMandatory) {
                    description.setRequired(true);
                    description.add(new ErrorHighlighter());
                }
                listItem.add(description);
                description.setModel(
                        new PropertyModel(model.getObject(), "nameTranslations[" + language.getId() + "]"));
                //model.bind(description, "nameTranslations["+language.getId()+"]");
                // form label for name
                description.setLabel(new ResourceModel("language." + language.getId()));
                listItem.add(new SimpleFormComponentLabel("languageLabel", description));
            }
        }.setReuseItems(true));
    } else {
        WebMarkupContainer container = new WebMarkupContainer("nameTranslations");
        TextField description = new TextField("name");
        description.setRequired(false);
        container.add(description);
        container.add(new Label("languageLabel", "").setVisible(false));
        add(container);
    }
}

From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributesPanel.java

License:Open Source License

/**
 * Renders custom attribute list//from w w w . ja  va  2 s.co  m
 * */
private void listAttributes() {
    LoadableDetachableModel attributesListModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            return getCalipso().findCustomAttributesMatching(
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch);
        }//load
    };

    attributesListModel.getObject();

    ////////////////
    // Pagination //
    ////////////////

    PaginationPanel paginationPanel = new PaginationPanel("paginationPanel", getBreadCrumbModel(),
            this.assetTypeCustomAttributeSearch) {

        IBreadCrumbPanelFactory breadCrumbPanelFactory = new IBreadCrumbPanelFactory() {
            @Override
            public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                //Remove last breadcrumb participant
                if (breadCrumbModel.allBreadCrumbParticipants().size() > 0) {
                    breadCrumbModel.allBreadCrumbParticipants()
                            .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                } //if

                return new AssetCustomAttributesPanel(breadCrumbModel.getActive().getComponent().getId(),
                        breadCrumbModel, AssetCustomAttributesPanel.this.referenceAssetType,
                        AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch,
                        AssetCustomAttributesPanel.this.isSearchOpen);
            }
        };

        @Override
        public void onNextPageClick() {
            activate(breadCrumbPanelFactory);
        }

        @Override
        public void onPreviousPageClick() {
            activate(breadCrumbPanelFactory);
        }

        @Override
        public void onPageNumberClick() {
            activate(breadCrumbPanelFactory);
        }
    };

    add(paginationPanel);

    /////////////////
    // List header //
    /////////////////

    List<String> columnHeaders = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch
            .getColumnHeaders();

    ListView headings = new ListView("headings", columnHeaders) {
        @Override
        protected void populateItem(ListItem listItem) {
            final String header = (String) listItem.getModelObject();

            Link headingLink = new Link("heading") {
                @Override
                public void onClick() {
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.doSort(header);
                }
            };
            listItem.add(headingLink);
            String label = localize("asset.customAttributes." + header);
            headingLink.add(new Label("heading", label));
            if (header.equals(
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.getSortFieldName())) {
                String order = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.isSortDescending()
                        ? "order-down"
                        : "order-up";
                listItem.add(new SimpleAttributeModifier("class", order));
            }
        }
    };

    add(headings);

    /////////////////////
    // Attributes List //
    /////////////////////

    final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt");

    if (this.referenceAssetType != null) {
        add(new Label("add", localize("asset.assetTypes.addCustomAttributeToType",
                localize(this.referenceAssetType.getNameTranslationResourceKey()))));
    } //if
    else {
        add(new WebMarkupContainer("add").setVisible(false));
    } //else

    ListView listView = new ListView("attributesList", attributesListModel) {
        AssetType referenceAssetType = AssetCustomAttributesPanel.this.referenceAssetType;

        @Override
        protected void populateItem(ListItem listItem) {
            final AssetTypeCustomAttribute attribute = (AssetTypeCustomAttribute) listItem.getModelObject();

            if (attribute.getId().equals(selectedAttributeId)) {
                listItem.add(new SimpleAttributeModifier("class", "selected"));
            } else if (listItem.getIndex() % 2 != 0) {
                listItem.add(sam);
            } //if

            // listItem.add(new Label("name", new PropertyModel(attribute, "name")));
            listItem.add(new Label("name", localize(attribute.getNameTranslationResourceKey())));
            listItem.add(new Label("formType",
                    new Model(localize("asset.attributeType_" + attribute.getFormType()))));
            listItem.add(new Label("mandatory",
                    new Model(attribute.isMandatory() ? localize("yes") : localize("no"))));
            listItem.add(
                    new Label("active", new Model(attribute.isActive() ? localize("yes") : localize("no"))));

            Link edit = new Link("edit") {
                @Override
                public void onClick() {

                    activate(new IBreadCrumbPanelFactory() {
                        @Override
                        public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                            AssetCustomAttributeFormPagePanel assetCustomAttributeFormPagePanel = new AssetCustomAttributeFormPagePanel(
                                    id, breadCrumbModel, attribute);
                            if (referenceAssetType != null) {
                                assetCustomAttributeFormPagePanel.setReferenceAssetType(referenceAssetType);
                            } //if
                            return assetCustomAttributeFormPagePanel;
                        }
                    });

                }//onClick
            };

            listItem.add(edit);

            if (referenceAssetType == null) {
                listItem.add(new WebMarkupContainer("add").setVisible(false));
            } //if
            else {
                WebMarkupContainer add;

                if (referenceAssetType.getAllowedCustomAttributes().contains(attribute)) {//if this customAttribute is used  

                    add = new Fragment("add", "removeLink", this);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Allowed custom attributes : "
                                + referenceAssetType.getAllowedCustomAttributes());
                    }
                    add.add(new Link("link") {
                        //remove a custom attribute to the Asset Type in question
                        @Override
                        public void onClick() {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                                logger.debug("Removing attribute : " + attribute.getName());
                            }
                            AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes()
                                    .remove(attribute);
                            if (logger.isDebugEnabled()) {
                                logger.debug("new Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                            }
                            //Remove last 2 breadcrumb participants
                            if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) {
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                            } //if

                            activate(new IBreadCrumbPanelFactory() {
                                @Override
                                public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                                    return new AssetTypeFormPagePanel(
                                            getBreadCrumbModel().getActive().getComponent().getId(),
                                            getBreadCrumbModel(),
                                            AssetCustomAttributesPanel.this.referenceAssetType);
                                }
                            });

                        }//onClick
                    });
                } else {//if this customAttribute is not used, can add it
                    add = new Fragment("add", "addLink", this);

                    add.add(new Link("link") {
                        //Adds a custom attribute to the Asset Type in question
                        @Override
                        public void onClick() {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                                logger.debug("Added custom attribute : " + attribute.getName());
                            }
                            AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes()
                                    .add(attribute);
                            if (logger.isDebugEnabled()) {
                                logger.debug("New Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                            }
                            //Remove last 2 breadcrumb participants
                            if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) {
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                            } //if

                            activate(new IBreadCrumbPanelFactory() {
                                @Override
                                public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                                    return new AssetTypeFormPagePanel(
                                            getBreadCrumbModel().getActive().getComponent().getId(),
                                            getBreadCrumbModel(),
                                            AssetCustomAttributesPanel.this.referenceAssetType);
                                }
                            });

                        }//onClick
                    });
                }

                listItem.add(add);
            } //else
        }
    };

    add(listView);
    add(new WebMarkupContainer("noData").setVisible(this.assetTypeCustomAttributeSearch.getResultCount() == 0));

}