Example usage for org.apache.wicket.markup.html.list LoopItem setOutputMarkupId

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:org.hippoecm.frontend.plugins.standards.tabs.TabbedPanel.java

License:Apache License

public TabbedPanel(String id, TabsPlugin plugin, List<TabsPlugin.Tab> tabs, MarkupContainer tabsContainer) {
    super(id, new Model<>(-1));

    if (tabs == null) {
        throw new IllegalArgumentException("argument [tabs] cannot be null");
    }/*from w w w  . j  a  v a  2 s.c om*/

    this.plugin = plugin;
    this.tabs = tabs;
    this.tabsContainer = tabsContainer;

    setOutputMarkupId(true);

    final IModel<Integer> tabCount = new AbstractReadOnlyModel<Integer>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Integer getObject() {
            return TabbedPanel.this.tabs.size();
        }
    };

    // add the loop used to generate tab names
    tabsContainer.add(new Loop("tabs", tabCount) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(LoopItem item) {
            final int index = item.getIndex();

            final WebMarkupContainer titleMarkupContainer = getTitleMarkupContainer(index);
            item.add(titleMarkupContainer);
            item.add(newBehavior(index));
            TabsPlugin.Tab tab = getTabs().get(index);
            if (tab.isEditorTab()) {
                final WebMarkupContainer menu = createContextMenu("contextMenu", index);

                item.add(menu);
                item.add(new RightClickBehavior(menu, item) {

                    @Override
                    protected void respond(AjaxRequestTarget target) {
                        getContextmenu().setVisible(true);
                        target.add(getComponentToUpdate());
                        IContextMenuManager menuManager = findParent(IContextMenuManager.class);
                        if (menuManager != null) {
                            menuManager.showContextMenu(this);
                            StringValue x = RequestCycle.get().getRequest().getQueryParameters()
                                    .getParameterValue(MOUSE_X_PARAM);
                            StringValue y = RequestCycle.get().getRequest().getQueryParameters()
                                    .getParameterValue(MOUSE_Y_PARAM);
                            target.appendJavaScript("Hippo.ContextMenu.renderAtPosition('" + menu.getMarkupId()
                                    + "', " + x + ", " + y + ");");
                        }
                    }
                });
            }
            item.setOutputMarkupId(true);
        }

        @Override
        protected LoopItem newItem(int iteration) {
            return newTabContainer(iteration);
        }

    });

    panelContainer = newPanelContainer("panel-container");
    cardView = new CardView(tabs);
    panelContainer.add(cardView);
    add(panelContainer);
}