Example usage for org.apache.wicket.markup.html.panel Panel getMarkupId

List of usage examples for org.apache.wicket.markup.html.panel Panel getMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.panel Panel getMarkupId.

Prototype

public String getMarkupId() 

Source Link

Document

Retrieves id by which this component is represented within the markup.

Usage

From source file:org.opensingular.lib.wicket.util.tab.BSTabPanel.java

License:Apache License

private Component buildTabControll() {
    return new ListView<Pair<String, Integer>>("tab", tabMap.keySet().stream().collect(Collectors.toList())) {
        @Override//w w  w. j a v  a  2 s  .co  m
        protected void populateItem(ListItem<Pair<String, Integer>> item) {

            Panel currentPanel = tabMap.get(item.getModelObject());

            if (item.getIndex() == 0) {
                item.add($b.classAppender("active"));
            }

            WebMarkupContainer tabAnchor = new WebMarkupContainer("tabAnchor");
            tabAnchor.add($b.attr("href", "#" + currentPanel.getMarkupId()));
            tabAnchor.add($b.attr("aria-controls", currentPanel.getMarkupId()));

            tabAnchor.add(new Label("header-text", item.getModelObject().getLeft()));
            item.add(tabAnchor);
        }
    };
}

From source file:org.xaloon.wicket.component.jquery.JQueryTabPanel.java

License:Apache License

public void init(List<? extends ITab> tabs, JQueryBehavior queryBehavior) {
    if (queryBehavior.isCreatedFromComponent()) {
        add(queryBehavior);/*from ww  w. j a va 2  s.  c o  m*/
    }
    final WebMarkupContainer container = new WebMarkupContainer("tabs");
    container.setOutputMarkupId(true);
    add(container);
    queryUITabBehaviorItem = new JQueryUITabBehaviorItem() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getMarkupId() {
            return container.getMarkupId();
        }

        @Override
        public String getTheme() {
            return (theme != null) ? theme : super.getTheme();
        }
    };
    queryBehavior.addChild(queryUITabBehaviorItem);

    RepeatingView titles = new RepeatingView("tab");
    titleContainer = new WebMarkupContainer("tc");
    titleContainer.setOutputMarkupId(true);
    container.add(titleContainer);
    titleContainer.add(titles);

    contentContainer = new WebMarkupContainer("cc");
    contentContainer.setOutputMarkupId(true);
    container.add(contentContainer);

    RepeatingView contents = new RepeatingView("content");
    contentContainer.add(contents);

    for (int i = 0; i < tabs.size(); i++) {
        final Panel content = tabs.get(i).getPanel(TAB_ID + i);
        WebMarkupContainer title = new WebMarkupContainer(TAB_ID + TAB_TITLE_ID + i);
        title.setOutputMarkupId(true);
        titles.add(title);
        content.setOutputMarkupId(true);
        contents.add(content);

        if (content instanceof PageTabContainerPanel) {
            /**
             * generate <li><a href="url">title</a></li>
             * page will be loaded instead of panel
             */
            final PageTabContainerPanel panel = (PageTabContainerPanel) content;
            AbstractLink link = new AbstractLink("link") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("href", urlFor(panel.getPageClass(), panel.getParameters()));
                }
            };
            link.add(new Label("title", tabs.get(i).getTitle()));
            title.add(link);
        } else {
            /**
             * generate <li><a href="#markupId">title</a></li>
             * panel will be loaded
             */
            AbstractLink link = new AbstractLink("link") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("href", "#" + content.getMarkupId());
                }
            };
            link.add(new Label("title", tabs.get(i).getTitle()));
            title.add(link);
        }
    }
}